Retain scroll-position of a listbox

G

Guest

I have on a site some very populated listboxes, now, when the user scrolls
the listbox to chose some items, and then clicks a button, thus, a postback
starts, the scoll position of the listbox is reseted.

Is there a way to keep the scroll position? Is the functionality build in,
or, is additional javascript needed?
 
A

Aytaç ÖZAY

Hi,

Yes, there is a way. Bu t you must coded it:) Before you click a button, you
must Store the selectedindex(listbox's) in a session, then the postback
starts. After that in page load method, you can set the selectedindex from
the session's value.

Have a nice work,

Aytaç ÖZAY
Software Developer


"the friendly display name"
 
C

Chris Fulstow

Maybe something like this (C#) using some JavaScript:

string position = "n";
string scrollScript="" ;
scrollScript += "<script language='javascript'>";
scrollScript += "document.forms[0].ListBox1.selectedIndex = " +
position + ";";
scrollScript += "<" + "/" + "script>";

Page.RegisterStartupScript("", scrollScript);
 

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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top