Re: When resubmitting a long page, how do you preserve the vertical position on the page?

From: Bob Barrows [MVP] (reb01501_at_NOyahoo.SPAMcom)
Date: 09/04/04


Date: Sat, 4 Sep 2004 08:29:50 -0400

Mike wrote:
> Hello,
>
> I've got a long page that resubmits itself to pass variable settings
> like this:
>
> http://localhost/hwlist2.asp?user=Kithmaker&user2=&sortby=cNumber
>
> the problem is that when the page reloads the user starts at the top
> again. Is there any way of preserving the vertical position the user
> is viewing on the page?
>
> Thanks,
> Mike

This is mostly a client-side coding question. Let me address the small
portion that will be asp-related:

Is it long due to lengthy text? Or is it long due to many controls on the
page? If the latter, you can add a hiiden textbox to the page and use
client-side code in the onsubmit event to populate that textbox with the
name of the control that curently has focus. Then your server-side code can
pass that id back to the winow_onload event:

<%
dim sActiveControlID
sActiveControl = Request.Form("txtActiveControlID")
'substitute Querystring for Form if using Get
...
%>
<html>
<head>
<script language=javascript>
function window_onload() {
var sActiveID = "<%=sActiveControlID%>"

 where the focus() method can be used in conjunction with the
getElementByID() method to set focus to to that control. You may also need
to use the scrollIIntoView() method to cause it to scroll into view:

var obj=document.getElementByID(sActiveID)
obj.focus()
obj.scrollIntoView()
...

For more detail, see one of the scripting groups, or one of the groups with
"dhtml" in their name. The abopve is air code and I did not bother looking
up the proper syntax or spelling of the methods used in the client-code
section. The DHTML documentation (as well as the documentation for all MS
technologies) can be found here: http://msdn.microsoft.com/library. Drill
down in the menu starting at Web Development down to HTML and Dynamic HTML.

HTH,
Bob Barrows

-- 
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM" 


Relevant Pages

  • RE: Mistake in MSDN
    ... > So its an HTMLServer control which does not submit. ... > All other HTML controls ... > This causes your function to be called first, before the client-side submit ... > script is called. ...
    (microsoft.public.dotnet.framework)
  • RE: access control in a Repeater from javascript
    ... client-side script code, we should know its client-side ID in the html ... we must read it after the certain control has been added ... the actual id that'll be writeout to client html document. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Volume Control use
    ... Volume Control that is broken. ... mixer mode you on the right side a Microphone listed on the Playback ... This is wrong and if you look at the device below the Mike it shows ... As root you typed #alactl restore but an Update has removed this capability. ...
    (Fedora)
  • Re: OE6 keyboard shortcut for "Show/Hide Preview Pane"?
    ... Thank you for trying Mike. ... menu does not list "Message in HTML". ... I've tried this while viewing an HTML message as plain text in the ... preview pane and also in its own window. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Volume Control use
    ... When you click it up if your in the Alsa mixer mode you on the right side a Microphone listed on the Playback tab. ... To use this bad system first turn up the Master and Master Mono to the top and set Mike to the top. ... OK the Volume Control will control your playback on the Alsa Mixer and the mike gain is on the OSS mixer. ...
    (Fedora)