Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 12-Feb-13 21:37pm
Rate this: bad
good
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[^]
  Permalink  
v2
Comments
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
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
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">        
    </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.
  Permalink  
Comments
chandu devathi at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2014
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