How to disable an ASP.NET button when clicked
Originally I thought this was going to be simple by using the onclientclick property of the ASP.NET button server control but although that worked to disable the button, it did not continue with the form postback. Eventually after quite a bit of Googling and some more failed attempts I figured out this solution:
MyButton.Attributes.Add("onclick", "this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(MyButton, "").ToString());
With the code above now the button onclick event will look something like this:
The button is disabled AND then the button post back method is called.
Technorati Tags: ASP.NET