错误pageMethod未定义 [英] error pageMethod is undefined
本文介绍了错误pageMethod未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
i get error pageMethod is undefined
我的代码是:
hi
i get error pageMethod is undefined
my code is:
script type="text/javascript">
function runTest() {
var ffg = PageMethods.Test();
alert(ffg);
}
</script>
并将其添加到.aspx页面
and add this in .aspx page
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
我的default.cs页面是
my default.cs page is
[System.Web.Services.WebMethod]
public string Test()
{
return "hello";
}
推荐答案
您的测试
方法需要static
YourTest
method needs to bestatic
[System.Web.Services.WebMethod]
public static string Test()
{
return "hello";
}
function runTest() {
PageMethods.Test(OnSucceeded, OnFailed);
}
function OnSucceeded(response) {
alert(response);
}
function OnFailed(error) {
alert(error);
}
[System.Web.Services.WebMethod]
public static string Test()
{
return "hello";
}
这篇关于错误pageMethod未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文