Disabling buttons when a form is submitted

D

dougloj

Hi.

Can anyone tell me the best way to disable a group of buttons on an
asp.net form when the form is submitted?

I know I can't disable the submit button in JavaScript before the form
goes back to the server, because that would prevent the submission from
making it back to the server. I've found that if I set a time out in
JavaScript when the submit button is first clicked, the form gets
submitted to the server, then the time out occurs back on the client,
at which time I disable the buttons on the form. In the server code, I
re-enable the buttons before returning to the client.

This seems to work OK, but I was wondering if anyone knew of a slicker
and/or cleaner way of doing it. Any thoughts?

TIA

Doug
 
S

shaharh

add handler to the onsubmit of the form and disable each button that u
want:

<body>
<form id="form1" runat="server" onsubmit="return
DisableButtons();">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
<script type="text/javascript">
function DisableButtons()
{
document.getElementById('Button1').disabled = true;
return true;
}
</script>
</body>
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top