views:

2026

answers:

3

I've 2 asp.net pages..page A and page B. On clicking a link on page A, user gets redirected to page B.When on page B, if user clicks browser's back button,I need to forcefully invoke page refresh of page A. How do i achieve this functionality? Note:Code needs to be compatible across different browsers...ie IE, firefox, opera, etc

Thanks for reading.

A: 

You could set a session variable on page B and check to see if that session variable exists on page A and handle it accordingly.

hypoxide
thanks...but will browser's back button click invoke Page_Load method of page A?
Steve Chapman
No, not guaranteed. You'll have to use Javascript, its the only thing that is guaranteed to run on a cached page.
Chad Grant
A: 

I'd say the best way to do it is telling the browser not to cache the page.

<%    Page.Response.Expires = 0;   %>

If that doesn't work to your needs, you'd need javascript to force the refresh.

Psuedo code:

if (cookie does not exist)
  set cookie with 10 second expiration
else if cookie exists {
  is cookie expired? {
     set new cookie
     refresh page
   }
}
Chad Grant
A word of warning, setting the expiration time to 0 will throw a "Webpage has expired" error in IE7 and force the user to refresh the page. This might throw your users off if they see that error page.
Bit Destroyer
no .
Chad Grant
how do i refresh an asp.net page using javascript?
Steve Chapman
+1  A: 

There is some button property like Autopostback, you can try it and see if ti helps!

Izabela