ScriptManager的EnablePageMethods属性用于设定客户端javascript直接调用服务端静态WebMethod

aspx

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">    </asp:ScriptManager>

 

aspx.cs

[System.Web.Services.WebMethod]
    public static String xxx(string name)
    {
        return "done for " + name;
    }

 

javascript:

<script type="text/javascript">
        function sayHello(){
            PageMethods.xxx("boxer", sayHelloCallback);
        }
        function sayHelloCallback(result){
            alert(result);
        }
    </script>

相关文章:

  • 2021-10-22
  • 2021-12-16
  • 2022-12-23
  • 2021-12-28
  • 2021-08-07
  • 2021-10-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
  • 2021-09-05
  • 2022-01-12
  • 2021-07-16
相关资源
相似解决方案