1

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.

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.