Click here to Skip to main content
13,191,877 members (41,329 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 13-Feb-13 2:44am
tried the second option, but its not working
Jαved 13-Feb-13 2:54am
it should work i dont know why it is not working.
Jαved 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171017.2 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2017
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