uhh... I don't think that is possible (the .NET way at
least). Basically I think you could do this by JavaScript.
Detect (somehow) with javascript if the backbutton was
clicked, and if so, refresh the page.
ASP.NET is more server-side oriented. And the action you
are performing is Client-Side. So you have to do it client
side.
According to
http://www.tek-tips.com/viewthread.cfm?
qid=897314 the detection of the Back button press is
impossible???
So I can suggest a way for you (the way I would do it).
Basically when you load the page, in a hidden field
somewhere have a time stamp of the loading date/time
i.e.
<INPUT TYPE="HIDDEN" NAME="TimeStamp" VALUE="Sep 6 2004
17:34:24">
And then also create a cookie with a timestamp (and set it
each time your page is loaded, but after you try to detect
the backbutton).
So now in your code run the javascript each time the page
is displayed/loaded (OnPageLoad I think???):
1. Retrieve the cookie timestamp value (into a var
cookieTimeStamp)
2. Retrieve the hidden form field value (into a var
pageTimeStamp).
After retrieving the values set the cookie to the current
time (so if you press the forward button the same thing
will occurr).
And then compare them. If the cookieTimeStamp is blank
(not set) or is less than the pageTimeStamp, then do
nothing. Otherwise reload the page. (you could actually do
this in one if statement, but I think this is easier to
present/explain).
When you reload the page that way, that will send a
request to the server which will cause your ASP code to be
executed again like you wanted.
I haven't done this before, but based on some other work I
have done, this should work
I know this is not exactly the Microsoft friendly way, but
if you really need to do this, then here is one way.
Actually I would be interested to see what other ways
people would come up with to do this.
Hope that helps.