Identify that the page is displayed due to the back button click of the browser
Posted Date Unknown Lovely Manuel 8 Comments

I have two pages in my website that uses a common master page. Page1 is the start up page and contains a link to Page 2. When I am in Page 2, I want to go back to Page 1 by clicking the 'Back' button of the Browser.Then I need to refresh/reload Page 1.

Please help with a sample code. Note that these pages are using a common master page.

See All Responses Below...
Message Rating
Posted on: 28/05/2013
I belive The method is to use a web user control and reuse it in as many pages as you need it by embedding it. You can show or hide each user controls embedded in pages( or you can load it in a place holder). If you tried to implement it in a web page, tracking each page contents might be tough when you hit back button (although not impossible and can be done using session object).

Posted on: 28/05/2013
use this , it will work fine for all case

protected override void OnPreRender(EventArgs e) 

 StringBuilder javaScript = new StringBuilder();

 javaScript.Append(" <script language=JavaScript> "); 
 javaScript.Append("window.history.forward(1); "); 
 javaScript.Append("</script> ");

 Page.RegisterClientScriptBlock("HistoryScript", javaScript.ToString()); 
Share this page across other social networking sites

Posted on: 28/05/2013

Also you can  disable the caching of data and it is able to track the back button press, also able to hide the back button

code example 


<script type="text/javascript" language="javascript">
document.attachEvent("onkeydown", my_onkeydown_handler);
function my_onkeydown_handler()
switch (event.keyCode)
case 116 : // F5;
event.returnValue = false;
event.keyCode = 0;
window.status = "We have disabled F5";

this will solve the issue

Posted on: 28/05/2013
I think Johnson's answer is right and I was referring to another to another scenario (as I mis understood your question) .

My commend is for this scenario

Is it possible to put a Back and next button on the web page which remembers the values when the page moves forward or backward using the web page buttons without using session variables?.


Share this page across other social networking sites

Posted on: 28/05/2013
Actually I don't want to disable or hide the Back button, I want the Back button enabled. But need to reload/refresh the coming page. I got many samples and are working fine for pages without master page. But I am using master page. 

Posted on: 28/05/2013
Why can you try to see HTML  page source when the page is rendered on the Browser with the master page and then adjust the code so that it behaves correctly. Right now it might be overlapping with some other code..
Share this page across other social networking sites

Posted on: 28/05/2013
just listen the backbutton and reload  the page
Posted on: 28/05/2013
All reload revents should write on master page page load event or prerender event
Share this page across other social networking sites

Please Login to Post Your Comments
Name (Max. 100 characters)
Please post your comments here
Select Language
Attach File(Max. Size: 2 MB)
A few simple rules when posting your Comments,
  1. Please post only answers relevant to the topic of discussion.
  2. Please dont misuse this site or do not be abusive, offensive, inappropriate,harass anyone on the boards or post ads or spam. Doing so will delete your inappropriate messages and will block or delete your account on this site. 

Academic Projects

Site optimized for IE7, 1280 X 768 and above. Copyright © 2010 - 2018 KTS InfoTech
Site Developed Using KTS WebCloud