window scroll position

W

Wayne Sepega

Ultimately what I need is a way to remember the scroll position of the form
on a post back. I have a button that posts back to the current form and if
there are no errors the form is reproduced, I want to scroll back to where
the user was when they clicked on the button.

I have an ASPX page with the following doc type:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd" >

I'm not a 100% sure what all the above means, though I do know (from help
with a co-worker) that it determines how the document is generated on the
client side. I have to leave the doc type that way for our standards, but
still need to do the following.

I have the following JAVASCRIPT in the same page:

alert("You've scrolled to " + document.body.scrollTop + " pixels.");

With the doctype tag I always receive 0 for the value, but if I remove the
doctype tag or set it to a different type, I receive the correct value. Is
there an equivalent of scrollTop in the above doc type?

Any help or points in the right direction are appreciated.
Thanks
Wayne
 
W

Wayne Sepega

I had tried SmartNavigation (replaced with MaintainScrollPositionOnPostback)
before, but for some reason it to does not work. I have a GridView on my
form that is tied to a large dataset (large in 30 or so rows), there are
buttons that are dynamically created and when pressed call a javascript
function. which looks like:

function confirmIt(url)
{
location.href = url;
}

Which now that I think about it, looks more like a redirect then a postback.
This could be why the above doesn't work for me.

I did however find the following on the web:

http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

Last of the sample code shows hot to get the x, y of the scroll and then I
also found

http://www.devhood.com/messages/message_view-2.aspx?thread_id=104625

Which had:

window.scrollTo(x, y);

This does the trick for me, for now. As I learn more and probably realize
what is wrong with my location.href I'll work on correcting it so I can use
the default property.

Thanks
Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top