) 11 Jul 06 23:14
I'm using this page as another step towards my goal of seeing if a
number already exists in a database, so I do a SQL count. The tutorial,
http://www.kynou.com/GetTutorial.aspx?TutorialID=51 , where you type in
the state inital and onblur(), then second box fills with the full
name. This tutorial works, but I'm trying to do a SQL count on the text entered, then notifiy the
user if that number exists or not in a db table. Whatever I type in, the div tag says 'null'.

I can get to where I successfully show the parameter passed to the Ajax Method, stateInitial, and the SQL string via the Return value for the div tag, but that's it. All else gives null.

I have the following code behind for my WebForm1.aspx v1.1 page:

Start code behind:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

<AjaxPro.AjaxMethod()> Public Function GetStateName(ByVal stateInitial As String) As String
'Return stateInitial
Dim strSQL As String = "Select count(*) from WBS_Table where [WBS Number] = '" & stateInitial & "'"
Dim cmd As New OleDbCommand(strSQL, sCon1)
Dim intCnt As Integer = cmd.ExecuteScalar()

If intCnt = 0 Then
Return "This is unique"
Return "Please enter another Number!"
End If
Catch ex As Exception
Return ex.ToString()
End Try
'Select Case stateInitial.ToUpper()
' Case "CA"
' Return "California"
' Case "NY"
' Return "New York"
' Case "IL"
' Return "Illinois"
' Case Else
' Return "What tha'!"
'End Select
End Function

Here's the html:

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
function getStateName(obj)
//function CallbackFunc(res)
//document.getElementById('txtStateName').value = res.value;
function CallbackFunc(res){
if (res.error != null)
// else
// alert(res.value);
//document.getElementById('txtStateName').value = res
txtStateName.innerHTML = res.value;

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<div>State Initial:</div>
<asp:textbox id="txtStateInitial" onblur="getStateName(this);" runat="server"></asp:textbox>
<div id="txtStateName"></div>