Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
Double Form Submit ASP.NET 2.0
Old 11-19-2010, 02:59 AM Double Form Submit ASP.NET 2.0
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
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
Jasonpv is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-19-2010, 06:56 PM Re: Double Form Submit ASP.NET 2.0
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
Does this make sense?
Jasonpv is offline
Reply With Quote
View Public Profile
 
Old 11-26-2010, 02:51 PM Re: Double Form Submit ASP.NET 2.0
Novice Talker

Posts: 8
Trades: 0
Try with OnClientClieck to call javascript.
__________________

Please login or register to view this content. Registration is FREE
e-webtemplates is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Double Form Submit ASP.NET 2.0
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16718 seconds with 11 queries