Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I click browser back button my previous page history is lost. I don’t want page refreshed when I click browser back button. Please give me solutions
Posted
Updated 23-Jan-12 0:44am
v2
Comments
What is the browser you are using ???

It doesn't work that way. Remember, the web is stateless, when you navigate to a page the browser doesn't know if its the first time or 14th time you have visited the page. ASP.NET handles postbacks by setting the viewstate but once you navigate away from the page then viewstate for that page is destroyed. Clicking the back button is like visiting the page for the first time again.
 
Share this answer
 
Comments
comred 23-Jan-12 7:07am    
5+
Rajesh Anuhya 23-Jan-12 7:11am    
Marked as Answer, have my +5
Manoj Kumar Choubey 23-Jan-12 7:28am    
+5
If you click the browser back button then ultimately page cycle runs again. So if you didn't maintain the view state or session value then it will delete all previous value for sure.
 
Share this answer
 
v2
Hi,

If you click the back button,in that button you can write if(ISPostback) in that loop you can write the retrieving code by using querystring or any other cookies.
If is post back means the page will be post backed once but the button contains previous page data.

Or

You can use ajax controls,it is partially postbacked the page,your content cannot be destroyed,only changed content can be updated.
 
Share this answer
 
Its a Browser behavior. You can re-fill the page by using viewstate or session state. Or you can prevent the back button usage.
 
Share this answer
 
Comments
[no name] 23-Jan-12 14:35pm    
No it is not browser behavior. This is how ASP.NET works. Once the page has been served it is forgotten. ViewState is valid for postbacks not for initial page loads which is what a back button refresh would register as.
Hi friend,
i think it is better to store the state of the page in session, when you go back restore the session to its original state.
 
Share this answer
 

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