Thursday, July 9, 2009

PageMethods is undefined ASP.NET AJAX


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

1. PageMethods needs to be static
[WebMethod]
public static int MethodName()
{
}


2. Enable pageMethods in scriptManager

<asp:ScriptManager ID="ScriptManager1" runat="server" 
                   EnablePageMethods="true">
</asp:ScriptManager>

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]

WebMethod] 
[Microsoft.Web.Script.Services.ScriptMethod]
public static string GetRecords()  
{  
//DO something  
}



Hope this helps
www.tips-fb.com
Shout it
Stumble Upon Toolbar
Submit this story to DotNetKicks vote it on WebDevVote.com add to del.icio.us saved by 0 users
Subscribe to Feeds

1 comments:

Anonymous said...

Add script manager attribute as EnablePartialRendering="true".


About Me

My Photo
amiT jaiN
Hi, I am amiT jaiN Software engineer working on C#.NET and ASP.NET technologies
View my complete profile

Comments

.NET Resources

Find More Articles


Subscribe To Feeds

Subscribe by E-mail

Enter your email address:

Delivered by FeedBurner


Subscribe in your favorite reader

This site is best viewed with || You may get errors in proper display of this site if using Internet explorer


C#.NET Articles and tutorials,ASP.NET Articles - blog by amiT jaiN