How to make the scroll bar of the ListBox remain the last position after the page is postback refreshed
http://anforen.5d6d.com/
http://four-corner.appspot.com/
You can use JavaScript to handle:
<script language= "JavaScript" >
function AutoScroll ()
{
var list = document.getElementById ("ListBox1");
if (!list | |!list.multiple | | | list.length = 0) return;
var lastitem = list[list.length-1];
if (lastitem.selected)
{
Lastitem.selected = true;
Return
}
Else
{
Lastitem.selected = true;
lastitem.selected = false;
}
for (Var i=0 i < list.length; i++)
{
if (list[i].selected)//or list.selected?
{
List[i].selected = true;
Return
}
}
}
</script>
Add in Page_Load:
protected void Page_Load (object sender, EventArgs e)
{
Page.registerstartupscript ("MyScript", "<script language=javascript defer= ' true ' > AutoScroll () </script > ");
}
This allows the postback to be implemented, and the vertical scroll bar of the listbox is still in place before the page is sent back.
ref:http://codingforums.com/showthread.php?t=80998