Link to home
Start Free TrialLog in
Avatar of webressurs
webressursFlag for Norway

asked on

Prevent double submit when users doubleclick an asp:button

When users doubleclick an asp:button the form is added twice in the database. What is the best and easiest way to prevent this?

Can it be done in the Stored Procedure (SQL)? Or by using Jquery? Or code behind by disabling the button on submit?

Hope some of you experts can give me a good advice :)
Avatar of basicinstinct
basicinstinct
Flag of Australia image

you could disable the submit button (when it's clicked) using javascript (jquery) - that doesn't PREVENT double submit but makes it less likely to happen.
to prevent it from happening you would need to try to detect the double submit issue - like, for instance, not honoring two subsecond requests in a row with the same exact data in the same exact session.
in your submit code, verify if the same record exists (eg only the previous record or a record submitted in the last x seconds), you can also add an identifyer and check if that exists.
if there is no result, you can create a new record
ASKER CERTIFIED SOLUTION
Avatar of webressurs
webressurs
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of webressurs

ASKER

Disables button when clicking it.