Pagemethods in asp.net

My Pagemethod implementation is not working in Chrome browser.
I have ASP.NET 3.5 web application developed in VS 2008.

The code below not working in chrome or Safari:

function FetchDataOnTabChange(ucName)
{ 
    PageMethods.FetchData(ucName, OnSuccessFetchDataOnTabChange, OnErrorFetchDataOnTabChange);
}

function OnErrorFetchDataOnTabChange(error)
{   
   //Do something
}

function OnSuccessFetchDataOnTabChange(result)
{
   //Do something  
}

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

This should work in all browsers by following the steps below:

  • The page method must have the
    System.Web.Services.WebMethod
    attribute. [WebMethod]
  • The page method must be public.
    [WebMethod] public …
  • The page method must be static.
    [WebMethod] public static …
  • The page method must be defined on
    the page (either inline or in the
    code-behind). It cannot be defined
    in a control, master page, or base
    page.
  • The ASP.NET AJAX Script Manager must
    have EnablePageMethods set to true.

This is from a working application

aspx page:

/* the script manager could also be in a master page with no issues */
<asp:ScriptManager ID="smMain" runat="server" EnablePageMethods="true" />
<script type="text/javascript">
    function GetDetails(Id) {
        PageMethods.GetDetails(doorId);
    }
</script>

code behind:
[System.Web.Services.WebMethod]
public static void GetDetails(string Id)
{

}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x