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.
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.
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.
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.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With