Loading to specific point on page

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hello

I have a datalist on a webpage which initially displays
all the entries in the item view mode. When I select an
item to edit it reloads the page and displays the selected
item in the edit view. The problem I have with this is
that it reloads the browser window displaying the top of
the form. This is fine for an entry at the top of the
grid but if it is towards the bottom the user has to
scroll down the list to the appropiate item. Is their way
to reload the page without it going back to the top of the
page. Or is it best to reorder my grid displaying the
selected item as the first in the list. If so how do I do
this?

Thanks

David
 
Two techniques I have seen, although I don't know the full extent on browser
compatibility. One is to turn Smart Navigation on, and let IE take care of
keeping the page location. The other is to use the
Page.RegisterStartupScript to send a snippt of javascript that sets the
focus on a particular control.
 
James said:
Two techniques I have seen, although I don't know the full extent on
browser compatibility. One is to turn Smart Navigation on, and let IE
take care of keeping the page location. The other is to use the
Page.RegisterStartupScript to send a snippt of javascript that sets
the focus on a particular control.

Please note that Smart Navigation will only work in Internet Explorer.
 
Hi

You could return a script to the client that will scroll the element you
want into view

Example: This should scroll myElement into view
( runs on onload event to make sure element is ready )
<html>
<head>
<script>
function setPos(sElementID){
if(document.getElementById)
{
var e = document.getElementById(sElementID);
if(e!=null) e.scrollIntoView(true);
}
}
</script>
</head>
<body onload="setPos('myElement')">
<br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br>
<div id="myElement">ho ho I scrolled into view ;)</div>
</body>
</html>

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
 
Back
Top