Wednesday, March 28, 2012

PageMethod problems

Hi Everyone -

I have a master page setup, and i would like to use ajax in one of the pages that are to be used as a content page.

In the javascript portion of the detail page, i have some procedures that are marked as webmethods

 [WebMethod()]public void LoadGrid3() {#region LoadGrid3 DataSet ds3 =new DataSet(); DataTable dt3 = ds3.Tables.Add("Customer");

In the javascript side (presentation)

"javascript" type="text/javascript"> function findData() { var request; var AlertDiv = document.getElementById("AlertDiv"); AlertDiv.style.display =""; request = PageMethods.Update(onSearchComplete);} function onSearchComplete(results) { var AlertDiv = document.getElementById("AlertDiv"); AlertDiv.style.display ="none"; alert(results);} function findData_callback(res){ alert("here");}

script language="javascript" type="text/javascript"> function findData() { var request; var AlertDiv = document.getElementById("AlertDiv"); AlertDiv.style.display =""; request = PageMethods.Update(onSearchComplete);} function onSearchComplete(results) { var AlertDiv = document.getElementById("AlertDiv"); AlertDiv.style.display ="none"; alert(results);} function findData_callback(res){ alert("here");} script>

"text/C#" runat="server"> [WebMethod]public void Update() { LoadGrid3(); }

scripttype="text/C#"runat="server">

[WebMethod]

publicvoid Update()

{

LoadGrid3();

}

script>

On the button click event - i have it call the function findData

the PageMethods get popped as an error

Microsoft JScript runtime error: 'PageMethods' is undefined

Am i missing something somewhere??

thanks

tony

Hi,

PageMethods must be declared as public static methods in beta1.

No comments:

Post a Comment