Re: Preventing multiple form submissions (multiple postbacks)

Tech-Archive recommends: Fix windows errors by optimizing your registry

ashelley_at_inlandkwpp.com
Date: 06/25/04


Date: Fri, 25 Jun 2004 21:50:14 GMT

On 25 Jun 2004 14:39:20 -0700, solenoidpowered@yahoo.com (Diane Selby)
wrote:

>Steve-
>
>Redirecting to another page is a solution, but maybe not the solution
>we are looking for. In most cases, we want to display the same page
>after the button click. So, heading off to a "please wait" page and
>then back to the original page would be a bit bewildering for the
>user. I could see lots of complaints about that...
>
>What I'm dreaming of is a JavaScript client side method that will pop
>up an alert if the user clicks the button more than once before the
>results return. We may have to wire up a script to each button, but
>I'd rather have something that would work on a page level somehow...
>
>Anyhow, if anyone has something they can suggest, that would be fresh,
>yo!
>
>DD
>

add something like this

System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("if (Page_ClientValidate() == false) { return false; }} ");
sb.Append("this.value = 'Wait...';");
sb.Append("this.disabled = true;");
sb.Append(this.Page.GetPostBackEventReference(this.<buttonname>));
sb.Append(";");
this.<buttonname>.Attributes.Add("onclick", sb.ToString());

remeber to change <buttonname> to the actual name of u're button.

-Adam


Quantcast