Disabling a Button Until Processing is Complete

Here’s the scenario – let’s say you have an Insert subroutine, called ‘doInsert’. You want to immediately disable the Submit button, so that the end-user won’t click it multiple times, therefore, submitting the same data multiple times.

For this, use a regular HTML button, including a Runat=”server” and an ‘OnServerClick’ event designation – like this:
<INPUT id=”Button1″ onclick=”document.form1.Button1.disabled=true;” type=”button” value=”Submit – Insert Data” name=”Button1″ runat=”server” onserverclick=”doInsert”>

Then, in the very last line of the ‘doInsert’ subroutine, add this line:
Button1.enabled=”True”

That’s all there is to it!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>