ASP.NET2.0 - ICallbackEventHandler(2) 无刷新回调创建步骤

  1. <body>

    <form id="form1" runat="server">

    <div>

    <button onclick="CallServer()">CallServer</button>

    </div>

    </form>

    </body>

  2. <script language="javascript" type="text/javascript">

    function CallServer()

    {

    var product = "test";

    <%= ClientScript.GetCallbackEventReference(this, "product", "ReceiveServerData",null)%>;

    }

     

    function ReceiveServerData(rValue)

    {

    alert(rValue);

    }

    </script>

  3. private string CallBackValue = string.Empty;

     

    string ICallbackEventHandler.GetCallbackResult()

    {

    return CallBackValue + ",Light the passion Share the dream";

    }

     

    void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)

    {

    this.CallBackValue = eventArgument;

    }

posted @ 2008-05-06 14:41  许晓光  阅读(301)  评论(0编辑  收藏  举报