Reputation: 941
I need to disable the submit button, to prevent double posting.
I added the following attributes to the asp:button:
UseSubmitBehaviour="false"
OnClientClick="this.disabled='true';this.value='Please wait ...'"
This works only if on the first click all controls of the form are valid. But if any one of the asp:RequiredFieldValidor fails, the button is disabled until the page is refreshed.
Upvotes: 1
Views: 1171
Reputation: 440
Use the below code:
OnClientClick="if (Page_ClientValidate()) { this.disabled='true';this.value='Please wait ...'}"
Explanation
Page_ClientValidate()
This method is used for asp.net client side validation. So, if you page in client side validated then only disable your text box.
Upvotes: 3