Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i used this code in anchor tag

href="javascript.history.go(-1) BACK

after i do some operation in current page.its going back every operation i have done in the current page.

eg : i have two pages index.aspx
and next is xyz.aspx .i have done some operation in xyz.aspx.if i press back it should go to index.aspx.at present its going back whatever operation i have done in xyz.aspx and at last its coming to index.aspx.
Posted
Updated 11-Oct-11 21:57pm
v4
Comments
Herman<T>.Instance 12-Oct-11 4:24am    
is this backbutton of browser or your own back button? Response.Redirect("index.aspx")?

I suggest do not use the browser back button for going for previous page.

Instead use your obwn navigation back / fwd and use Response.Redirect.
You can store the UrlReferrer of the current page (ViewState of the page) and on click of back button navigate to the stored UrlReferrer of the page.

You can refer to following article:
http://codebetter.com/petervanooijen/2005/07/19/a-back-button-for-asp-net-pages/[^]
 
Share this answer
 
Comments
yerrojumeher 12-Oct-11 5:15am    
thanks vivek
This happens because you're (presumably) doing lots of postback/refreshes on XYZ. If you want the 'back' to work, you need to do those postbacks through AJAX so the whole page isn't refreshed.

However, this isn't really a good use of the back button. Users expect 'back' to take them back to the previous page and discard anything they have done on the current one. What you want is a 'continue' link or similar which actively navigates back to Index (so the history would be Index->XYZ->Index).
 
Share this answer
 
store page path in session then try.
 
Share this answer
 
You can store the UrlReferrer of the current page (ViewState of the page) and on click of back button navigate to the stored UrlReferrer of the page using response.redirect.
 
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