Click here to Skip to main content
15,887,962 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After redirecting a page from Page1 to Page2 and again when I go back to Page1 using the "Back" button in the internet explorer, the Page_Load of Page1 is getting called. But When I redirect from Page2 to Page3, and When I go back, the Page_Load of Page2 is not getting called. Again when I go back, the Page_Load of Page1 is getting called.
Only the Page_Load of Page1 is getting called when traversed in the reverse order.

Page1 -> Page2 -> Page1 [Page_Load of Page1 is called]

Page1 -> Page2 -> Page3 -> Page2 [No Page_Load is called]

Page1 -> Page2 -> Page3 -> Page2 -> Page1 [Page_Load of Page1 is called]
a
How does this work, Could someone explain me?
Posted

The page load event is always fired.

If you don't get page_load this is because something (most probably the browser) decided to cache the page.
It could also be server side caching.

To fix your issues you must tell the browser not to cache the page.

Typically you'd add in your page load
VB
Response.Cache.SetCacheability(HttpCacheability.NoCache);
 
Share this answer
 
Comments
Herman<T>.Instance 21-Jun-12 8:59am    
My 5!
Pascal Ganaye 21-Jun-12 9:14am    
Merci
Hey Dear,

Please check your reverse code in button click event of page 3.
It may have some wrong code.
I just check whatever you want to do and it working properly.
Are you using
HTML
Responce.Redirect("Default2.aspx");

on button click event of page 3.
 
Share this answer
 
v2
as per my understanding you want to navigate to one page to other page.

1)Add 3 buttons in a page(btn1, btn2, btn3), now under btn1 click wrie the code as shown below
Response.Redirect("http://www.google.com");
same way you can give the page name where you want navigate when you click on button.
Response.Redirect("page1.aspx");

2)Same way you can use linkbutton also, add linkbutton -->go to the properties -->set the PostBackUrl value as your page where you want to navigate
<asp:linkbutton runat="server" id="lnk1" postbackurl="~/AboutUs.aspx" text="About Us" xmlns:asp="#unknown">
 
Share this answer
 
I got the solution. It was the problem due to caching. Solution 1 worked for me. Thanx a lot for all those who responded. :D
 
Share this answer
 
I think you should have disabled page caching in page1 otherwise it will no call page_load method on browser's back button.
 
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