People tend to double click buttons if an app is taking some time to respond, and this could lead to errors or problems with the user request. In this article I will give you a step by step guide on how to prevent double click in ASP.netOverview
You can normally press a button you can make a countless amount of click before post back. This is very tedious is you are making an insert to your data base because is going to insert the same information over and over.
As you can see in the image above we have a button login to prevent a double click we can make it with JavaScript adding the following code into out asp button:
OnClientClick=”this.disabled = true; this.value = ‘loading…’;” UseSubmitBehavior=”false”
This has to stop the double or multiples clicks, as you can see in the image bellow the button is disable.
Put you can also add this lines of codes in the script section.
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
function BeginRequestHandler(sender, args) { var oControl = args.get_postBackElement(); oControl.disabled = true; }
This last method not only prevent that the event click can make the actions programed twice, till is done the post back put also the other event like focus or key press so you have to know went used this method.
This Concludes Prevent double click ASP.net
Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!
Happy Hosting!
Rodolfo Hernandez