-
January 4th, 2012, 10:45 AM
#1
[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
-
January 4th, 2012, 12:13 PM
#2
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?
R.I.P. 3.5" Floppy Drives
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones." - Albert Einstein
-
January 4th, 2012, 12:46 PM
#3
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.
-
January 4th, 2012, 05:21 PM
#4
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.
-
January 5th, 2012, 10:33 AM
#5
Re: need back button listener method
Setting the cacheability to nocache seems to work. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|