Click here to Skip to main content
11,790,613 members (63,244 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET
i am having a listbox with autopostback on. Now, whenever autopostback occurs scroll goes back to top, i want to maintain the scroll bar to the last item selected.

Posted 12-Feb-13 20:37pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

There are three ways of applying the property to a web page.

You can set it programmatically

Page.MaintainScrollPositionOnPostBack = True
In the page declaration

<%@ Page MaintainScrollPositionOnPostback="true" %>
Or in the web.configs <system.web> section.

<pages maintainScrollPositionOnPostBack="true" />

check this link-
Maintain scroll position of listbox[^]
Deepak Manuja at 13-Feb-13 2:44am
tried the second option, but its not working
Jαved at 13-Feb-13 2:54am
it should work i dont know why it is not working.
Jαved at 13-Feb-13 2:57am
I have updated the answer check the link.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


set the height and width of the list box and set over flow as scroll as below.
<asp:listbox id="lstBox" runat="server" height="50px" width="100px" style="overflow:scroll;" xmlns:asp="#unknown">

this will maintain the scroll position of the list box to the previous selected position.

MaintainScrollPositionOnPostback="true" this is optional, this got nothing to do with list box scroll bar position. this is for overall page scroll position. better you can set this, so that no need to scroll down again to that position after post back.

hope it helps.
chandu devathi at 31-Jan-14 4:16am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 1,114
1 Maciej Los 825
2 KrunalRohit 686
3 CPallini 611
4 ppolymorphe 610

Advertise | Privacy | Mobile
Web01 | 2.8.1509028.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100