2

Hey looking for method to disable button after clicked, but I guess only after it passes validation because need to enter a second time.

EDIT :

Looking for a disable function which does the following
1) Disables the button onclick
2) when a user hits the back button in the browser the button is no longer disabled

Currently have

<asp:Button ID="btnProceedStepTwo" runat="server" Text="Proceed &nbsp;&rarr;" CssClass="button" OnClick="btnProceedTwo_Click" />

and in code behind

btnProceedStepTwo.Attributes.Add("onclick", "this.disabled=true;" + GetPostBackEventReference(btnProceedStepTwo).ToString());
4
  • You are guessing what your requirements are? Commented Jun 29, 2011 at 15:13
  • Hey..how about taking some time to explaing the question a little better with some sample code you have used so that people who can answer need not start with 100% guessed code? Commented Jun 29, 2011 at 15:13
  • Am i understanding you correctly, you want to disable the button when all validators are valid from codebehind and not because you want to prevent the user from double-click the button at short interval? Why not setting btnProceedStepTwo.Enabled = False from codebhind after the validation? Commented Jun 29, 2011 at 15:25
  • Hey sorry scratch that about validation. I just noticed it works fine regardless. What I am looking for is that when a user submits the button, it disables and loads next page. This works and is fine. But when a user hits the back button in the browser (because this is a multi step form) the button is still disabled. How do I renable it ? Commented Jun 29, 2011 at 15:29

1 Answer 1

2

You can disable submit button before page postback. Here is a link describing use of javascript to do so: Disable Button before Page PostBack in ASP.Net

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.