473,395 Members | 1,348 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,395 software developers and data experts.

How to save horizontal scroll bar position on page postback

I have a table that displays one row of images (thumbnails). When a
user clicks on an image it opens up a bigger image below it. The row
has about 20 cells. I have a <divtag which allows the user to scroll
left and right to see all the images. The problem is that when the
user scrolls to the middle and clicks on the image. The click causes a
post back and the page loads again and the scroll bar goes to the
left.

I need to know how to save the horizontal scroll bar position of the
table and re position the scroll bar at the same position when the
page loads.

I am doing this in c# and using image buttons in each cell of the
row. The images are kept in the database.

Jun 4 '07 #1
5 10147
On Jun 4, 3:07 pm, RobertK <rob96...@gmail.comwrote:
I need to know how to save the horizontal scroll bar position of the
table and re position the scroll bar at the same position when the
page loads.
use scrollLeft property :
http://msdn2.microsoft.com/en-us/library/ms534617.aspx

Jun 5 '07 #2
On Jun 4, 9:50 pm, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
On Jun 4, 3:07 pm, RobertK <rob96...@gmail.comwrote:
I need to know how to save the horizontal scroll bar position of the
table and re position the scroll bar at the same position when the
page loads.

use scrollLeft property :http://msdn2.microsoft.com/en-us/library/ms534617.aspx
This works ok with the page scrolling. I need some code to force a
scrollbar of a div tag to move to a position.

I tried the following which doenst seem to work.
document.getElementById('Div1').style.scrollleft=s omevalue;

how can I set a scrollbar position of a panel or div on load??

Jun 8 '07 #3
On Mon, 04 Jun 2007 21:07:10 -0000, in comp.lang.javascript RobertK
<ro******@gmail.com>
<11**********************@o5g2000hsb.googlegroups. comwrote:
>| I have a table that displays one row of images (thumbnails). When a
| user clicks on an image it opens up a bigger image below it. The row
| has about 20 cells. I have a <divtag which allows the user to scroll
| left and right to see all the images. The problem is that when the
| user scrolls to the middle and clicks on the image. The click causes a
| post back and the page loads again and the scroll bar goes to the
| left.
Fix the postback action:
<img src="..." onclick="ShowImage(); return false;" />
>| I need to know how to save the horizontal scroll bar position of the
| table and re position the scroll bar at the same position when the
| page loads.
Alternatively use Lightbox, Greybox, Thinbox etc
>| I am doing this in c# and using image buttons in each cell of the
| row. The images are kept in the database.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jun 9 '07 #4
Jeff North said the following on 6/9/2007 7:00 AM:
On Mon, 04 Jun 2007 21:07:10 -0000, in comp.lang.javascript RobertK
<ro******@gmail.com>
<11**********************@o5g2000hsb.googlegroups. comwrote:
>| I have a table that displays one row of images (thumbnails). When a
| user clicks on an image it opens up a bigger image below it. The row
| has about 20 cells. I have a <divtag which allows the user to scroll
| left and right to see all the images. The problem is that when the
| user scrolls to the middle and clicks on the image. The click causes a
| post back and the page loads again and the scroll bar goes to the
| left.

Fix the postback action:
<img src="..." onclick="ShowImage(); return false;" />
Clicking an image has no default behavior so returning false from the
onclick of an img doesn't make a lot of sense.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jun 10 '07 #5
dd
On Jun 4, 11:07 pm, RobertK <rob96...@gmail.comwrote:
The problem is that when the user scrolls
to the middle and clicks on the image. The
click causes a post back and the page loads
again and the scroll bar goes to the left.
You could use a session cookie to maintain the position of the
scrollbar. What I think you really want though, is to change what
happens when the thumbnails are clicked on. I think you want to stop
it doing a navigation and instead just load the image into
the .innerHTML property of the DIV that shows the larger image.
Returning false from the onclick handler should prevent a navigation.
This will be quicker because it won't be loading the whole page all
the time, and as a side-effect, the scrollbar position will of course
remain the same.

Jun 10 '07 #6

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

Similar topics

4
by: Timo | last post by:
We have a long page of links (LinkButtons). Is it possible to save the scroll position so that when a postback occurs after a link has been clicked, we can return the page to its scroll state? Our...
5
by: JezB | last post by:
There are a few references on the net about how to restore a page's scroll position over a postback. This is a simple one which works for me: eg....
4
by: Emmanuel | last post by:
Hi, I have placed a DataList control inside a panel control to obtain a scrollable list using the overflow:auto attribute. The rows in the data list contains and edit LinkButton to enable...
3
by: rmunson8 | last post by:
I have added Panel control to a web page which contains a GridView. The Panel's ScrollBars property is set to auto. When I select the Select CommanField button for a row (which obviously causes a...
6
by: | last post by:
Hi all, I have a long web form on asp.net 2.0. When I go at the bottom and click on submit, a postback occurs and if there are any validation errors (no client-side checking being done), the...
5
by: C Watson | last post by:
Hi, I'm wondering if anyone can help me with AJAX in ASP.NET 1.1. I have a very specific feature that I would like to use it for. I have a rather long form that the users use to enter data...
0
by: Keithb | last post by:
The maintain scroll position on postback feature works as expected with my site running under localhost on the development machine. When the files are posted to an IIS 6.0 web server running on a...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
1
by: wmbrae | last post by:
I trying to make a javascript document reader in 2 frames. The left frame displays the document, the right frame shows a list of document links. This is as far as I got ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.