Disable Submit Button

  • Thread starter Thread starter jack-e
  • Start date Start date
J

jack-e

Hi,

Can someone please provide me with an example of how to disable the
submit button once clicked (using javascript i guess). Keep in mind I
also have to invoke a server side function which processes the form.

Thanks in advance.

Jack
 
jack-e said:
Hi,

Can someone please provide me with an example of how to disable the
submit button once clicked (using javascript i guess). Keep in mind I
also have to invoke a server side function which processes the form.

Thanks in advance.

Jack

Use the Attributes collection to set the onclick to disabled the button
and submit normally:

button1.Attributes.Add("onclick","javascript:document.getElementById('"
+ button1.ClientID + "').disabled=true;" +
this.GetPostBackEventReference(button1));

reference:

http://www.codeproject.com/useritems/DisableSubmitButton.asp
 
Much shorter form:

button1.Attributes.Add("onclick","this.disabled=true;return true;");

Eliyahu
 
Eliyahu said:
Much shorter form:

button1.Attributes.Add("onclick","this.disabled=true;return true;");

Eliyahu

Use the Attributes collection to set the onclick to disabled the button
and submit normally:

button1.Attributes.Add("onclick","javascript:document.getElementById('"
+ button1.ClientID + "').disabled=true;" +
this.GetPostBackEventReference(button1));

reference:

http://www.codeproject.com/useritems/DisableSubmitButton.asp

Hmmm, that didn't seem to work for me. Could you provide sample code if
so? For completeness here....
 
Try to submit the from and then to disable the button. If you disable first
the button, the button is not considered pressed (disabled control are not
posted).

Patrice

--

 
Craig,

You can check it on any server-side button. "this" is the client-side
reference to the button itself and "return true" takes care about bubbling
the event up.

Eliyahu

 
Could be. This I didn't check. I've just optimized the size of the code.

Eliyahu

Patrice said:
Try to submit the from and then to disable the button. If you disable first
the button, the button is not considered pressed (disabled control are not
posted).

Patrice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top