Skip to content

Instantly share code, notes, and snippets.

@BruceHubbard
Created January 6, 2011 20:24
Show Gist options
  • Save BruceHubbard/768508 to your computer and use it in GitHub Desktop.
Save BruceHubbard/768508 to your computer and use it in GitHub Desktop.
Prevent Double Click In Web Forms
public static void PreventDoubleClick(Page page, Button button, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("if (Page_ClientValidate() == false) { return false; }} ");
sb.Append("this.value = '" + message + "';");
sb.Append("this.disabled = true;");
sb.Append(page.ClientScript.GetPostBackEventReference(button, String.Empty));
sb.Append(";");
button.Attributes.Add("onclick", sb.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment