【发布时间】:2011-07-13 16:50:37
【问题描述】:
我在 javascript 中调用 PageMethod。像这样:
function DeleteBatchJS2()
{$find('mdlPassword').hide();
var pswd = $('#txtPassword').val();
var userInfo = get_cookie("UserInfo");
PageMethods.AuthenticateAndDelete(
userInfo,
pswd,
onSuccess(),
onError1());
}
function onSuccess(result)
{alert(result);}
function onError1(result)
{alert(result);}
现在这是奇怪的部分:人们会认为调用 PageMethods 会在运行时发出一 (1) 个警报。 onSuccess 函数或 onError1 函数。但是——我收到两个警报,都说“未定义”。
事实上,当我在 VB 代码隐藏中放置断点时(如函数中的第 3 或第 4 行代码),在我可以进入我的代码之前,我会收到两个警报框。两个警报,然后我的代码中断了。
这对我来说毫无意义。我错过了什么吗?
谢谢,
杰森。
附: -- 这里是 WebMethod 函数的源代码。另请注意,它确实会进行 WCF 调用。
<WebMethod()> _
Public Shared Function AuthenticateAndDelete(ByVal UserInfo As String, ByVal Password As String) As Boolean
Dim Client As New LetterWriterClient
Dim bo As New BatchOperations
Dim UserNumber As String
Dim UserName As String
'Extract the user name and number from the user info cookie string
UserName = GetValueFromVBCookie("UserName", UserInfo)
UserNumber = GetValueFromVBCookie("UserNumber", UserInfo)
'Now validate the user
If bo.ValidateActiveDirectoryLogin("Backoffice", UserName, Password) Then
AuthenticateAndDelete = Client.Delete_dat_BatchSQL(UserNumber)
Client.Close()
Else
AuthenticateAndDelete = False
End If
End Function
【问题讨论】:
标签: javascript asp.net asynchronous webmethod pagemethods