Hi all, I know this subject has been widely covered online and is a known issue with asp form submission handling. I have implemented code which I believed should have solved the problem once and for all but it seems to have done nothing but broke the workaround I already had in place.
A bit of background...this form is currently inside of an update panel (ajax) with form validation group. When I was first presented with this issue I knew it had to be a client side double-click or multiple clicks from the user having no indication that the form was being processed. To remedy this I added a updateprogress div that covers the entire page which the user immediately saw when the submit button was clicked and form validation passed. This mostly worked but I still one multiple order that had been processed, granted much better than where we were before. When I saw this one multiple order I decided to dig a bit deeper and found a javascript solution online that basically disabled the button after validation had passed. Here is the code I used to add this javacode to the onclick event of the button, which I should mention, already has a call to a behind code C# function:
Button Code:
Code:
<asp:ImageButton ID="imgbtnWebsitePaymentPro" runat="server" ImageUrl="http://www.webmaster-talk.com/images/shopping-cart/confirm-order.jpg" OnClick="imgbtnWebsitePaymentPro_Click" ValidationGroup="submit" Style="height: 16px" />
Behind Code that adds JS:
Code:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SetSubmitClick();
...
}
}
protected void SetSubmitClick() {
StringBuilder sb = new StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("var oldPage_IsValid = Page_IsValid; var oldPage_BlockSubmit = Page_BlockSubmit;");
sb.Append("if (Page_ClientValidate('" + imgbtnWebsitePaymentPro.ValidationGroup + "') == false) {");
sb.Append(" Page_IsValid = oldPage_IsValid; Page_BlockSubmit = oldPage_BlockSubmit; return false; }} ");
sb.Append("this.onclick = null;");
sb.Append(ClientScript.GetPostBackEventReference(imgbtnWebsitePaymentPro, null) + ";");
sb.Append("return true;");
string submit_button_onclick_js = sb.ToString();
imgbtnWebsitePaymentPro.Attributes.Add("onclick", submit_button_onclick_js);
}
I have also tried this instead of "this.onclick = null;" above:
Code:
sb.Append("this.disabled = true;");
My question is, why is the above solution not working for me and how can I remedy this? Thank you for any insight!
Last edited by Jasonpv; 11-19-2010 at 03:13 AM..
Reason: Added more information on what has already been attempted
|