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>

posted @ 2010-10-14 11:11  wiseshrek  阅读(224)  评论(0编辑  收藏  举报