ASP.NET 2.0 無刷新

前臺腳本,nr 爲傳與後臺的參數 爲eventArgument的值,divid爲前臺context的值,這裏用是div的id.

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

         function GetServer(nr,divid)
         {
            var message = nr;
            var context = divid;
            <%=sCallBackFunctionInvocation%>
         }
        
         function bGetServer(nr,divid)
         {
            var message = nr;
            var context = divid;
            <%=sCallBackFunctionInvocation%>
         }
        
         function ShowServerTime(Message, context) {
           document.getElementById(context).innerHTML=Message;
         }
</script>

 public string sCallBackFunctionInvocation;

  void Page_Load(object sender, System.EventArgs e)
  {
   sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "ShowServerTime", "context");
  }

    #region ICallbackEventHandler 成員
    string ajaxvalue = "";
    public string GetCallbackResult()
    {
        return ajaxvalue;
    }

    public void RaiseCallbackEvent(string eventArgument)
    {
        ajaxvalue = eventArgument;
    }

    #endregion

發佈了54 篇原創文章 · 獲贊 1 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章