There are several work arounds. My own solution is to place 2 buttons on the
form; one is visible and the other is hidden like this:
<input id="btnPreSubmit" type="button" value="Submit"
onclick="SubmitAndDisable();">
<asp:button id="btnSubmit" Runat="server" CssClass="Hidden"
CausesValidation="True"></asp:button>
The hidden class should be defined in your styles section as this:
..Hidden
{
display:none;
}
When the user clicks on the visible button the following javascript executes
the Click event of the real button and disable the displayed button:
<script language="javascript">
function SubmitAndDisable()
{
var btn = document.getElementById("btnPreSubmit");
btn.disabled = true; //this will disable the button that is visible to the
user
btn = document.getElementById("btnSubmit");
btn.click(); //this will execute the real submit button
}
</script>
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Guzman" wrote:
> Hi, i want to disable a button after i click it, so the button it is not
> submited twice.
> The thing is that i'm working with the onclik event in the server side, and
> in the server side i disable the button, but sometimes the users click the
> button twice really fast, and i don't want this to happen.
> Does someone know how can i disable the button on the client side??
> Can i Submit button both ' runat=server ' and Disable OnClick ? because i
> been trying this but its not working...
>
> Thanks for any help!
>