Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browser Back button

Status
Not open for further replies.

croydon

Programmer
Apr 30, 2002
253
EU
Could someone please tell me how I can simulate using the Back button in IE. I want to give users the option to go to the previous page, either to re-start with a clean selection or modify the existing selection (i.e. the Back button).

From what I have read, the answer seems to be to use ("javascript:history.go(-1);"), but I can't seem to get this to work from my button.

I am using VB.NET

Thanks for your help.

 
Thanks ca8msm. I tried this but I had no OnClientClick event on my asp button. I then found an article that said this event is only available in the 2005 version of VB.NET.

Is that correct? I am using VS.NET 2003.

 
Yes, that is correct - it is only available in version 2.0 of the framework.

For your older version, try using the Attributes.Add method of the Button and add a javascript "onclick" event.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm, I think I have the answer.

In my row of buttons, instead of using a web form button for this function I have used an HTML button.

There is no other functionality required other than re-displaying the previous selections and (unless I'm missing something) this seems to work ok.
 
Yes, you can do that as well (either method will work). You may also wish to consider a server-side solution in case your users don't have javascript capabilities.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi, this should work fine:
Code:
<input type="button" onclick="history.go(-1)" value="Return" />

I dont know asp.net's refferer server variable, but if you google for it, I guess you can easilly make some serverside-redirect, based on refferrer.

Be aware though, that not always the server will be availible to detect the refferer (depends on browser).

You could trick this by using sessions, database-sessions, etc. But it all depends: How important is this function for you? Are you willing to use a lot of time on this? If not, dont care about the users who dont have JS. They can press the back-button in theire browser instead - if you ask me!

Dont use JS for vital functions, like password/authentication, etc. as it will reveal your logic for your users. It will also allow bypass/manipulation at a higher grade than server-side validation/control.

Anyhow, I recommend JS for "helping users", but always let there be some kind of backup-alternative way of using your pages.

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top