如何使用Ajax调用VB asp.net代码中的函数

时间:2013-11-27 18:13:11

标签: javascript jquery asp.net ajax vb.net

嘿嘿每个人我都不能接受这个工作,我已经看了一遍,无法找到我的问题。有人可以帮帮我吗?

这是我的代码的副本

<script src="scripts/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type = "text/javascript">
    function ShowCurrentTime(oSrc, args) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "EmergencyShelterInsert.aspx/GetCheckForClients",
            data: '{ }',
        dataType: "json",
        success: function OnSuccess(response)
        {
            document.getElementById("<%=lblCheckforClient %>").style.display = "inherit"
            alert("Didn't Work");
        },
       failure: function (response)
        {
            alert("Didn't Work");
        }
    });
}

功能背后的代码

<System.Web.Services.WebMethod()> _
Public Sub GetCheckForClients()
    Dim blnResults As Boolean = False
    Dim BLL As New CBuisnessLogicLayer
    Dim strFirstName As String = Server.HtmlEncode(TextBoxFirstName.Text)
    Dim strLastName As String = Server.HtmlEncode(TextBoxLastName.Text)
    Dim strDateOfBirth As String = Server.HtmlEncode(TextBoxDateOfBirth.Text)
    Dim strShelterID As String = m_strShelterId

    blnResults = BLL.CheckForClients(strFirstName, strLastName, strDateOfBirth, strShelterID)

    If blnResults = True Then
        LinkButtonCheckForClient.Visible = True
        LinkButtonViewHistory.Visible = True
    Else
        LinkButtonCheckForClient.ValidationGroup = False
        LinkButtonViewHistory.Visible = False
    End If

End Sub

aspx页面内容。

            <td>
                <asp:TextBox ID="TextBoxDateOfBirth" runat="server"  ></asp:TextBox>
                <%-- <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Date of Birth cannot be empty." ControlToValidate="TextBoxDateOfBirth" Display="Dynamic"   ></asp:RequiredFieldValidator>--%>
                <input id="ButtonSubmits" type="button" value="Check user" onclick = "ShowCurrentTime()" />
            </td>

非常感谢你寻找。

0 个答案:

没有答案