Monday, March 26, 2012

PageMethods is Undefined


its Urgent

I am Getting Same Error Could u please Help me Out..

Here is My Code..

using System.Web.UI.HtmlControls;

using System.Web.Services;

using Microsoft.Web.Script.Services;

using Microsoft.Web.Script;

[WebMethod]publicvoid GetNewMessage()


string str ="Hello";










Thanks in Advance,


Please its Urgent...

this is not sufficient to debug your error ... you need to show us the whole thing ... and what kind of error is that? JavaScript or server error?

check this post out ... same error as yours:

ScriptManager has to have EnablePageMethods=true and the WebMethod has to be static.

hi here is my full code..

aspx file

<bodystyle="margin: 0px;padding: 0px;">






<asp:ScriptReference Path="scripts.js" />









var str = PageMethods.GetNewMessage();


var result = document.createElement("div");var divlist = el("MessageList");

result.innerHTML = str;


function el(id)


return document.getElementById(id);



aspx.cs file..

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Web.Services;

using System.Web.Script.Services;

using System.Web.Script;

publicpartialclassRF_Message : System.Web.UI.Page


//ChatManger Chatmanger = ChatManger.GetChatManager();

protectedvoid Page_Load(object sender,EventArgs e)




#region Script callback function


publicstaticstring GetNewMessage()


string str ="Hello";

return str;




I am Getting Javascript Error While Running...

i am Getting alert Undefined...

RIght, you're executing that embedded script block as the page gets to it; pagemethods haven't been created yet (that happens during the clientside init, iirc. Try pulling all that code into your pageLoad() javascript function and see if that doens't help.

No comments:

Post a Comment