How to make the scroll bar of the ListBox remain the last position after the page is postback refreshed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.