[RESOLVED] need back button listener method
Hello,
Is there a way in the C# codebehind to setup a method that gets called when the user goes to the page from a back button press? For example, user is on page A, clicks a link to go to page B, then presses back button to return to page A. The codebehind on page A responds with something like backButton_Click() and carries out the desired proceedure.
I ask this because the Page_Load() method for page A is not invoked from back button presses, so I need something else.
Thanks
Re: need back button listener method
Can you handle the back button click event and check whether the current page loaded is Page A or Page B? Or maybe the page to be loaded is Page A?
Re: need back button listener method
The page to be loaded is page A. It needs to run the BackButton_Click() method on page load (just like Page_Load() would). I don't know how to do this.
Re: need back button listener method
first use this code to disable browser cache:
Code:
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
then use Session or other way to tell if the user access Page A for the first time or not. If not, then trigger some code in Page_Load().
Note server side has no way to tell if the user go back to Page A by clicking the back button or by retying the url, as all this happens at client side.
Re: need back button listener method
Setting the cacheability to nocache seems to work. Thanks.