Avoid calling events when page is refreshed
-
Hi, I want to avoid the events being called when page is refreshed. For eg: I call a button event that modifies some data in the database. If i press F5 on the same page again the button event is fired and data is modified. How do I avoid it? Thanks in advance Priya
-
Hi, I want to avoid the events being called when page is refreshed. For eg: I call a button event that modifies some data in the database. If i press F5 on the same page again the button event is fired and data is modified. How do I avoid it? Thanks in advance Priya
Hi Priya. What you're describing is a side-effect in most browsers when reloading a page that was the result of a POST operation. I'm not aware of anything you can do server-side to prevent this. But there are some things you can do to work around it. For example, if the POST inserts data in a database, you could include code that checks to see if the insert has already taken place (check for example if a record already exists with all the parameters). I think CodeProject does something like this to prevent double posting of the same forum messages. You can Google to find more workarounds. Here are a couple of threads where some other ideas are presented: http://forums.asp.net/1180000/ShowPost.aspx[^] http://forums.asp.net/2/776500/ShowPost.aspx#776500[^]