Tim Maxey .NET Technology Blog & Resources

Thursday, July 22, 2010

Disable hide ASP.NET button after submit click

Here is the easiest way to hide or rather disable the asp.net button control, or any other control for that matter, take this:

<div id="dwait" style="display:none">please wait, creating account...</div>
<div id="dBut"><asp:Button ID="Button1" runat="server" Text="Submit" OnClientClick="HideMe();" /></div>



function HideMe() {
var dw = document.getElementById("dwait");
var db = document.getElementById("dBut");
db.style.display = "none";
dw.style.display ="block";
}



When the asp.net button is clicked, it just hides the div of the button, or imagebutton (if you want) and shows the "wait" div. In the wait div you could put/style it however, like with an animated waiting or whatever... Enjoy!