乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      ASP.NET中防止頁面多次提交的代碼實現(xiàn)

       昵稱10504424 2013-02-18

      此處提供的代碼用來實現(xiàn)當(dāng)asp.net頁面中的某個Button被點擊后disable掉該頁面中所有的Button,從而防止提交延時導(dǎo)致的多次提交?;谥暗膐nceclickbutton腳本.

      //ASP.NET中防止頁面多次提交的代碼:javascript< script language=”javascript”> < !– function disableOtherSubmit() {
      var obj = event.srcElement;
      var objs = document.getElementsByTagName(’INPUT’);
      for(var i=0; i< objs.length; i++)
      {
      if(objs[i].type.toLowerCase() == ’submit’)
      {
      objs[i].disabled = true;
      }
      }
      } //–> < /script>//ASP.NET中防止頁面多次提交的代碼:asp.netpublic class PreventMultiClick : System.Web.UI.Page {
      protected System.Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Button Button2;
      protected System.Web.UI.WebControls.LinkButton LinkButton1; protected System.Web.UI.WebControls.Button Button3; private void Page_Load(object sender, System.EventArgs e)
      {
      this.GetPostBackEventReference(this.Button3);
      //保證 __doPostBack(eventTarget, eventArgument) 正確注冊 if(!IsPostBack)
      {
      System.Text.StringBuilder sb = new System.Text.StringBuilder();
      sb.Append(”if (typeof(Page_ClientValidate) == 'function’)
      {
      if (Page_ClientValidate() == false)
      {
      return false;
      }
      }”); //保證驗證函數(shù)的執(zhí)行 sb.Append(”if(window.confirm(’are you sure?’)==false) return false; “);
      //自定義客戶端腳本 sb.Append(”disableOtherSubmit(); “);
      // disable所有submit按鈕 sb.Append(this.GetPostBackEventReference(this.Button3));
      //用__doPostBack來提交,保證按鈕的服務(wù)器端click事件執(zhí)行 sb.Append(”; “);
      Button3.Attributes.Add(”onclick”,sb.ToString());
      }
      } #region Web Form Designer generated code override protected void OnInit(EventArgs e)
      {
      // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent();
      base.OnInit(e);
      }
      /// < summary> /// Required method for Designer support – do not modify /// the contents of this method with the code editor. /// < /summary> private void InitializeComponent()
      {
      this.Button3.Click += new System.EventHandler(this.Button3_Click); this.Load += new System.EventHandler(this.Page_Load);
      }
      #endregion private void Button3_Click(object sender, System.EventArgs e)
      {
      System.Threading.Thread.Sleep(3000);
      Response.Write(”Hello world!”);
      }
      } 此處只是disable掉所有的submit button, 我覺得其它的可提交控件也是可以通過類似的方法來disable的.

      以上就是ASP.NET中防止頁面多次提交的代碼實現(xiàn)。

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多