PDA

View Full Version : Clicking the Back button in ASPX and VB


bennettw
09-12-2003, 02:34 AM
I'm coding in ASPX and VB and trying to go back to the last web page the user accessed. I found the processModelInfo class but it is not enabled on the discountAPS server. Does any know anyother way to go back?

bennettw
09-13-2003, 02:45 AM
Thanks for responding. I'm trying to write in code the equivalent of clicking the Back button in my browser. I want to have a button on my web page that will take the user to the previous site visited. In Java script there was the window.back (or window.history). Is there the same in .Net running IIS 6?

BB

bruce
09-13-2003, 09:59 AM
Not quite sure what you want to do.

Can you elaborate on what you mean by "going back"?

[b]quote:Originally posted by bennettw

I'm coding in ASPX and VB and trying to go back to the last web page the user accessed. I found the processModelInfo class but it is not enabled on the discountAPS server. Does any know anyother way to go back?

</blockquote id="quote"></font id="quote">

bruce
09-14-2003, 01:22 AM
i don't think you can do this on the server side. THe web server has no knowledge of where the client visited before.

the only way you can do this is through client side scripting, like javascript

[b]quote:Originally posted by bennettw

Thanks for responding. I'm trying to write in code the equivalent of clicking the Back button in my browser. I want to have a button on my web page that will take the user to the previous site visited. In Java script there was the window.back (or window.history). Is there the same in .Net running IIS 6?

BB
</blockquote id="quote"></font id="quote">

Frank42
09-17-2003, 04:55 AM
If You want to use java script here it is.

<A href="javascript:history.back()">Go back

bajdev
10-03-2003, 02:46 AM
bennettw,

I believe you can get the page the user came from, from the ServerVariables collection

Try:
Request.ServerVariables("HTTP_REFERER")

I believe it holds the whole url where the user came from, but it may only hold the domain name. I don't remember off the top of my head.

Hope that helps.

Cheers,
bajdev

AllanS
10-20-2003, 12:49 PM
It is possible to do it server-side.

You need to capture the address of the calling page and persist it to survive postbacks. One example would be to use a hidden label. You put the following line in the Page_Load:

lblUrlReferrer.Text = Request.UrlReferrer.AbsolutePath.ToString

Note: It would be wise to put a try/catch around this line just in case there is no referrer page.


Next, you add a link button or form button to the page, then put the following line in the button's click event:

Response.Redirect(lblUrlReferrer.Text)


Yes, this is a roundabout way of doing it, but sometimes the javascript back() method won't take you to the page where you want to be (depending on the postback and redirection activity).

I hope this helps.


Allan Sieker
Eureka, MO