Avoid click of a button twice

This is a very common requirement that the user should not click on the button twice while submitting. The best option to use the below code on the page load

PostBackOptions pbOptions = new PostBackOptions(btnSave);
btnSave.OnClientClick = "this.disabled = true; this.style.cursor='wait';";
btnSave.OnClientClick += Page.ClientScript.GetPostBackEventReference(pbOptions);

If you are using a Image button, instead of this use the document.getElementById('ctl00_btnSave')

Hope this helps..

Cheers!!!

Comments

Popular posts from this blog

“Unable to retrieve the metadata for …” Error while using ASP.NET MVC 3

2012 - > 2013 : Happy New Year

Visual Studio 2013 and .NET 4.5.1