页面方法未定义

发布于 2024-12-17 01:03:58 字数 798 浏览 8 评论 0原文

我有一个带有 MasterPage 的页面,在母版页中,我有这个:

 <ajaxToolkit:ToolkitScriptManager ID="scriptManager" 
                                   runat="server" 
                                   AsyncPostBackTimeout="99999999"
                                   EnablePageMethods="true" />

我在后面的代码中有这个方法:

[WebMethod]
public void SavePreference(string graphVersion)
{
    //some code here
}

然后我有这个 javascript 函数:

 function lnkLearnHardWayclick(){ 
    if( $("#chkDontShowAgain").attr("checked") == "checked")
    {
        PageMethods.SavePreference('new');
    }
    $("#info").hide();
    $("#hardWay").show();
}

但是当我单击链接以使一切正常工作时,我得到了这个错误:

未捕获的引用错误:PageMethods 未定义

I have a page with a MasterPage, in the master page, I have this:

 <ajaxToolkit:ToolkitScriptManager ID="scriptManager" 
                                   runat="server" 
                                   AsyncPostBackTimeout="99999999"
                                   EnablePageMethods="true" />

And I have this method in the code behind:

[WebMethod]
public void SavePreference(string graphVersion)
{
    //some code here
}

And then I have this javascript function:

 function lnkLearnHardWayclick(){ 
    if( $("#chkDontShowAgain").attr("checked") == "checked")
    {
        PageMethods.SavePreference('new');
    }
    $("#info").hide();
    $("#hardWay").show();
}

But when I click on the link to make everything work, I get this error:

Uncaught ReferenceError: PageMethods is not defined

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

站稳脚跟 2024-12-24 01:03:58

母版页和用户控件不支持 PageMethods

PageMethods are not supported in master pages and user controls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文