Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
problem form click refresh button of browser than again btn click event fire .
my problem is this when i click button than form submit and respective method will run and return back into my page .aspx when i click refresh button of browser than it again post form and submit method would call for this my data base management is destroyed. also i want to submit form again with another parameter but not for browser refresh button .
how to stop refresh button to resubmit my form .
please give me some code because i read more article about resubmit.cause like browser have history and maintain state but server not maintain its state etc.





Rizwan khan
Posted

Hi,

I think you cannot avoid form to load on click of refresh button of the browser.
instead you can make use of "IsPostBack" property of the page.

The difference is when you click on refresh button, then value of "IsPostBack=false", but if click on button, "IsPostBack=true".

so before excecuting your code, you can check the value of "IsPostBack" property and place the code accordingly.

http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx[^]

hope it helps.
 
Share this answer
 
Comments
rizwan muhammed khan gouri 14-Jul-12 3:24am    
will you give me more help. i already know but how to resolve it give some code for this.
Karthik Harve 14-Jul-12 3:34am    
What i have understood from your question, i have answered for it. if you know already, then re-frame your question with proper explanation. we are not doing home work here.
Narra sreenu 29-Oct-12 8:08am    
testing
This is due to how browsers work. The first time you POST the page, the browser sends all the data, then returns back HTML to render. If you hit refresh (F5) then the browser re-sends the last POST request thus re-sending the information again. This causes duplication of record. One need to apply Post-Redirect-Get pattern for such scenarios/pages, where after an HTTP Post, instead of returning HTML, is redirected back to a page (either the same or another).

In case, you cannot redirect or not comfortable with redirect, have a look at these articles:
Refresh Page Issue in ASP.Net[^]
Stop Refresh after Submitting your Request[^]
Detecting Page Refresh[^]
 
Share this answer
 
Comments
rizwan muhammed khan gouri 18-Jul-12 1:55am    
for redirect self page my successful or error message was distroyed please give me more help.
/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900