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 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. I'm trying to do a count on the text entered, then notifiy the
user if that number exists or not. Whatever I type in, the second box
says '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
        AjaxPro.Utility.RegisterTypeForAjax(GetType(WebForm1))
    End Sub
    <AjaxPro.AjaxMethod()> Public Function GetStateName(ByVal
stateInitial As String) As String
        'Try
        '    sCon1.Open()
        '    Dim strRQ As String = txtStateInitial.Text.ToString()
        '    Dim strSQL As String = "Select count(*) from WBTbl where
[WBNum] = '" & strRQ & "'"
        '    Dim cmd As New SqlCommand(strSQL, sCon1)
        '    Dim intCnt As Integer = cmd.ExecuteScalar()
        '    sCon1.Close()
        '    If intCnt = 0 Then
        '        Return "This is unique"
        '    Else
        '        Return "Please enter another Number!"
        '    End If

        'Catch ex As Exception
        '    Return ex.ToString()
        'Finally
        '    sCon1.Close()
        '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:
*****
*****
<HEAD>
                <title>WebForm1</title>
                <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)
                {
                CSS.WebForm1.GetStateName(obj.value,CallbackFunc);
                }
                function CallbackFunc(res)
                {
                document.getElementById('txtStateName').value = res.value;
                }

                </script>
        </HEAD>
        <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>State Name:</div>
                        <input id="txtStateName" type="text">
                </form>
        </body>
</HTML>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Ajax.NET Professional" group.

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]

For more options, visit this group at http://groups.google.com/group/ajaxpro

The latest downloads of Ajax.NET Professional can be found at 
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---

Reply via email to