PageMethods Is Undefined ASP.NET AJAX

If you are getting PageMethods Is Undefined Error while using AJAX in ASP.NET or using a webservice than you need to check these things to resolve the issue

1. PageMethods needs to be static

public static int MethodName()

2. Enable pageMethods in scriptManager

<asp:ScriptManager ID="ScriptManager1" runat="server" 

3. add reference to script service in code behind
Add [Microsoft.Web.Script.Services.ScriptMethod] or [System.Web.Script.Services.ScriptService] in code behind below [WebMethod]

public static string GetRecords()  
//DO something  

Hope this helps

If you like this post than join us or share


Anonymous said...

Add script manager attribute as EnablePartialRendering="true".

Unknown said...

i'm using webusercontrol. i want to call C# function in this usercontrol, but the scriptmanager located in masterpage.

Anonymous said...

Thanks, I used to keep getting "PageMethods is undefined"... then i changed my method to be static and it works now :)


Anonymous said...

god byrjun

Anonymous said...

I think there is a bracket missing in #3.

Ramesh said...

I wan to handle event arguments in the above webmethod. How can i handle paramater based web methods? Please help me

Unknown said...

@Ramesh: Please refer Call Asp.Net WebService PageMethods Or WebMethod WIth Parameters Using JavaScript Or JQuery

Anonymous said...

No good

Find More Articles