Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii,
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.

Thanks
Posted

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

You can set it programmatically

VB
Page.MaintainScrollPositionOnPostBack = True

In the page declaration

VB
<%@ Page MaintainScrollPositionOnPostback="true" %>

Or in the web.configs <system.web> section.

VB
<pages maintainScrollPositionOnPostBack="true" />


check this link-
Maintain scroll position of listbox[^]
 
Share this answer
 
v2
Comments
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.
Hi,

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


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.
 
Share this answer
 
Comments
chandu devathi 31-Jan-14 4:16am    
ttt

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900