Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 20th, 2004, 09:44 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default return to exact location like the 'back' button

hello
i have a webpage, longPage.asp, that's about 2-3 pages long, and when a user clicks on a link in the middle of the page, say about 1.5pages down, he is directed to another page, does some crap, clicks on a button to update the info and he is redirected back to longPage.asp.

is there anyway i can return him to the location where he was viewing previously, i.e. 1.5pages down?? like what the 'back' button on our browser does.
Reply With Quote
  #2 (permalink)  
Old February 20th, 2004, 11:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You can use an HTML approach with hyperlinks, such as:

...
<a name="Section2"></a>
...

You don't need to put anything in the hyperlink text area for it to work. You reference this as:

<a href="longpage.asp#Section2">Back</a>

I don't know of any way using ASP, other than using ASP to dynamically create the hyperlink as above.
Reply With Quote
  #3 (permalink)  
Old February 20th, 2004, 11:44 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hmm..sounds like something feasible, but wouldnt that return the user to the page which will start from the anchor?
what i hope to do is to return the user to the page location exactly as it was before, e.g. he could scoll a few lines down the anchor, click on the link, then when he returns, he will be at that few lines down the anchor, and not at the anchor

is it possible? anyone with any ideas??

Reply With Quote
  #4 (permalink)  
Old February 21st, 2004, 12:58 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You could do the following to preserve a page's scroll position:

1) Create a hidden field in the form to save the value.
2) In the body onScroll event you need to run the following javascript
    myForm.myHiddenScrollField.value=document.body.scr ollTop;
3) All links on the page must force a post of the form. You could have the page post to itself, then you need to determine what link/button was pressed to determine what you would need to do. (i.e. For regular links, you would need to redirect to the correct page.)
4) When the page processes the form, save the hidden field's value to a session variable.
5) When the page draws itself, put the following in the body onLoad attribute:
    document.body.scrollTop=<value from the session variable>;
This will reposition the document to the saved scroll position.

The biggest impact of this process will be on what you have to change for links. You won't be able to link directly to other pages, you will have to always cause a form post, otherwise you won't be able to preserve the value.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old February 21st, 2004, 02:08 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

w0o0o
thanks bmains for ur suggestion, and
thanks alot planoie, your suggestion works nicely

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User's Exact Location (Country, City, Continent) hunzian78@yahoo.com ASP.NET 1.0 and 1.1 Professional 3 March 8th, 2006 12:49 AM
How to return a string to it's exact original (len EDCH123 Java Databases 0 January 25th, 2006 04:06 PM
Location of Access default command button icons ActuaryTm Access 2 September 16th, 2005 12:03 PM
Back Button DARSIN General .NET 0 March 1st, 2005 08:00 AM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM



All times are GMT -4. The time now is 07:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.