473,320 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

window scroll position

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
Apr 4 '06 #1
1 2075
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/tutoria.../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/mess...read_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

"Steven" <St****@discussions.microsoft.com> wrote in message
news:B4**********************************@microsof t.com...
If the users are using IE 5+ then set the DOCUMENT property of
'smartNavigation' to true.

"Wayne Sepega" wrote:
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

Apr 4 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian Sedwell | last post by:
Hi guys The following code works just fine in Netscape on MacOS and Windows. But in Explorer on MacOS and Windows it throws a type mismatch error at the point marked with the comment ³// bug out...
2
by: abs | last post by:
How to detect that user started to scroll the page ? Separately vertical and horizontal scroll. Is it possible ? Regards, ABS
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
3
by: Steve | last post by:
I want to force a window to scroll and am finding this to be an impossibly difficult task. First I tried using the API functions ScrollWindow and ScrollWindowEx but they do not work. The portion...
4
by: libsfan01 | last post by:
hi is it possible to position a div relative to the document window? so for example if the page is scrolled down the div in question does not move regards marc
3
by: superjacent | last post by:
Hope someone can help. I have a listbox displaying time periods in blocks of 15 mins for a 24 hour period, all up 96 rows. The listbox can only visibly show 20 rows a time. The default...
2
by: sachjn | last post by:
Hi, I need to have a table along with other UI items in page which resizes horizontally and vertically with the browser window. That means table should accoupy the remaining available space in...
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.