all groups > asp.net security > february 2006 >
You're in the

asp.net security

group:

Disabling buttons when a form is submitted


Disabling buttons when a form is submitted dougloj
2/23/2006 10:42:15 PM
asp.net security: 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
Re: Disabling buttons when a form is submitted shaharh NO[at]SPAM gmail.com
2/25/2006 3:10:27 AM
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>
AddThis Social Bookmark Button