Pagemethods in asp.net

后端 未结 1 496
刺人心
刺人心 2020-11-28 14:48

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 Safar

相关标签:
1条回答
  • 2020-11-28 15:04

    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)
    {
    
    }
    
    0 讨论(0)
提交回复
热议问题