How to save horizontal scroll bar position on page postback

R

RobertK

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 <div> tag 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.
 
J

Jeff North

| 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 <div> tag 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:
| 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
 
R

Randy Webb

Jeff North said the following on 6/9/2007 7:00 AM:
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.
 
D

dd

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.
 

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,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top