Thursday, December 28, 2017

Avoid double click of button in ASP.NET

  #region Disable button on click event
    override protected void OnInit(EventArgs e)
    {
        btnSubmit.Attributes.Add("onclick", "javascript:" +
                  btnSubmit.ClientID + ".disabled=true;" +
                  this.GetPostBackEventReference(btnSubmit));
        InitializeComponent();
        base.OnInit(e);
    }
    /// <span class="code-SummaryComment"><summary></span>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// <span class="code-SummaryComment"></summary></span>
    private void InitializeComponent()
    {
        this.btnSubmit.Click +=
                new System.EventHandler(this.btnAddPayment_Click);
        this.Load += new System.EventHandler(this.Page_Load);
    }
    #endregion disable button on click event

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.