Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing accidental double clicking on a button

I have a few controls that inherit from ASP.NET buttons and use onserverclick.

If the user clicks twice, the button fires two server side events. How can I prevent this?

I tried setting this.disabled='true' after the click (in the onclick attribute) via javascript, but that blocks the first postback as well.

like image 827
juan Avatar asked Sep 08 '08 19:09

juan


People also ask

How do I stop accidental double-click?

Open the Control Panel. Click or double-click the Mouse or Mouse Settings icon. In the Mouse Properties window, click the Buttons tab, if not already selected. On the Buttons tab, adjust the slider for the Double-click speed option, then click OK.

How can I avoid multiple clicks on my submit button?

Disabling the Submit Button In practice this can cause a form to be submitted, or some other event triggered, more than once. The second button however will only accept a single click and ignore all subsequent clicks. The trick is to use JavaScript to set the disabled property of the button to true.

How do I block a button after clicking?

There's another way you can disable the submit button after the first click. You can simply remove the onclick event handler by setting its value as null.

What happens if I double-click an item with my left mouse button?

In most cases, a double-click is with the left mouse button and is used to open or execute a file, folder, or software program. For example, programs and files in Microsoft Windows are opened by double-clicking the icon. To open your Internet browser, you would double-click the browser icon shortcut.


1 Answers

See this example for disabling control on postback. It should help you do what you're trying to achieve.

http://encosia.com/2007/04/17/disable-a-button-control-during-postback/

like image 73
Ryan Lanciaux Avatar answered Oct 24 '22 10:10

Ryan Lanciaux