Asp. NET to prevent refreshing the automatic trigger event solution _ Practical Tips
Source: Internet
Author: User
With ASP.net, server-side events are automatically triggered when the page is refreshed. To give a simple example, such as: a registration page, we fill out the registration information, if you press F5 Refresh, will automatically trigger to the button event, which caused another registration of trouble.
My previous solution: Use keyword queries, and if they are the same, prompt already.
But such a scheme cannot be used without a table, and he will resubmit it. In view of this, I am looking for a new solution, I am glad, in a friend's point, burst out such a solution, there must be a better solution, generous enlighten.
Solution: When refreshing, catch keypress and let him trigger other useless events.
1, capturing the F5 event JavaScript
Window.document.onkeydown = keystroke;
function keystroke ()
{
var key = Event.keycode;
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.