ScriptManager的EnablePageMethods

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>

你可能感兴趣的:(manager)