Homer2040
asked on
Disabling SUBMIT button to prevent multiple clicks.
Experts,
I have a .NET applicataion form that is called form a Master page. The application's SUBMIT button needs to NOT allow multiple clicks.
I have tried this in the Page_Load event and verified it's added:
btnSubmit.Attributes.Add(" onSubmit", "this.disabled=true;this.v alue='Plea se wait...';this.form.submit( )");
but it's still allowing multiple clicks and multiple submissions.
Any ideas?
Thanks.
H.
I have a .NET applicataion form that is called form a Master page. The application's SUBMIT button needs to NOT allow multiple clicks.
I have tried this in the Page_Load event and verified it's added:
btnSubmit.Attributes.Add("
but it's still allowing multiple clicks and multiple submissions.
Any ideas?
Thanks.
H.
or something like
btnSubmit.Attributes.Add(" onclick", "if (this.form.getAttribute(su bmitted)) return false;
this.form.setAttribute('su bmitted',t rue); this.value='Please wait...'");
btnSubmit.Attributes.Add("
this.form.setAttribute('su
ASKER
mplungjan,
Thanks for the catch, I did mean for it to be "onClick" on the button.
After correcting that (at least the behavior changed), the button is disabling (greying out) and the text is changing (Please Wait...), but the form is not submitting. It postsback like there is validation errors and there's not.
H.
Thanks for the catch, I did mean for it to be "onClick" on the button.
After correcting that (at least the behavior changed), the button is disabling (greying out) and the text is changing (Please Wait...), but the form is not submitting. It postsback like there is validation errors and there's not.
H.
As I said. You cannot disable the submit button when you submit.
Instead set a switch and test it
Instead set a switch and test it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yikes!
ASKER
mplungjan,
I am still getting multiple submits.
I think there was another suggestion...let me see.
H.
I am still getting multiple submits.
I think there was another suggestion...let me see.
H.
ASKER
mplungjan,
It looks like tusharashah's suggestion is working.
Thanks.
H.
It looks like tusharashah's suggestion is working.
Thanks.
H.
there is no onsubmit on a button, it is on the form.
onclick is what you wanted
perhaps this is what you want
<script>
var submitted = false;
</script>
and add onsubmit of the form
if (submitted) return false; submitted=true;
Michel