How to prevent multiple submission of ASP. NET buttons

Source: Internet
Author: User

I checked a lot of methods on the Internet, but it is not easy to do so. I 'd like to write one by myself. The idea is to use Javascript to change the next onclick event of the button to return false on the client when the button is pressed; in this way, the server page will not Post to the server if you click the button again before sending it back to the client. At the same time, change the style of the button to a line of text, and the cursor will also become an hourglass. After the server page is re-generated, the Button returns to the initial state. This method does not prevent F5 refreshing, but simply closes the F5 button. To prevent another submission during refreshing, you can clear some TextBox controls before returning the page, in this way, you can judge that if the TextBox is empty, no subsequent operations (such as writing a database) will be performed ). Or jump to another page after the background operation is successful to prevent malicious refresh. It is mainly used in the enterprise intranet, not to prevent hackers, so it is not very strict.

<Html xmlns = "http://www.w3.org/1999/xhtml"> 

Run code Copy code Save code Add to favorites

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.