Home
Manage Your Code
Snippet: How to prevent multiple clicks of a submit button in ASP.NET (ASP.NET)
Title: How to prevent multiple clicks of a submit button in ASP.NET Language: ASP.NET
Description: Prevent users from submitting multiple clicks from a submit button in ASP.NET, C#. Views: 464
Author: Homer McNeill Date Added: 11/27/2007
Copy Code  
protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        string prevent = "if (typeof(Page_ClientValidate) == 'function') { " + 
                         "if (Page_ClientValidate() == false) { return false; }} " + 
                         "this.value = 'Submitting...';" +
                         "this.disabled = true;" + this.Page.GetPostBackEventReference(ButtonSubmit) + ";";
        ButtonSubmit.Attributes.Add("onclick", prevent);
    }
}
Notes
found here: http://aspzone.com/blogs/john/articles/207.aspx