PageMethods not defined

Nahuel picture Nahuel · Nov 18, 2011 · Viewed 8.4k times · Source

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

Answer

Chamika Sandamal picture Chamika Sandamal · Nov 18, 2011

PageMethods are not supported in master pages and user controls.