I am configuring PageMethods to access server code using javascript. I get the error "PageMethods not defined" when I debug using firebug. server code also does not start.
I have the script manager "EnablePageMethods" set to true. My method is public and static, and it also sets the WebMethod attribute. However, I get the above error. Could this be because the script manager is located on the top-level main page, which has two child master pages, and then my page is called:
i.e.
Main main page (with script manager) → Main main page → Secondary main page → My page → My user control (using WebMethod)
Is it possible that this hierarchy is causing this problem?
This is a web method.
[System.Web.Services.WebMethod] public static void AddNote(string t) { int propid = 1; if (propid > 0) {
this is my javascript code:
function editNodes(t) { alert('test1'); alert(t); PageMethods.AddNote(t,OnSuccess,OnFailure); alert('method called'); } function OnSuccess() { alert('Success'); if (!navigator.appName == 'Microsoft Internet Explorer') { window.location.href = window.location.href; } } function OnFailure(error) { alert('Error:' + error); }
this is where i call it:
<a href="#" class="btngeneral" onclick="javascript:editNodes(2);">Save</a>
source share