简体   繁体   中英

Scroll to first selected Item in ASP.NET ListBox

is there an easy way to scroll an ASP.Net ListBox automatically to the first selected Item? The ListBox has SelectioMode="Multiple".

<asp:ListBox ID="LbSymptomCodesEdit" CausesValidation="true" ValidationGroup="VG_SAVE" Height="100%" Width="100%" runat="server"  SelectionMode="Multiple"></asp:ListBox>

The ListBox is in the EditItemTemplate of a FormView inside of an UpdatePanel. jQuery is possible but it would be great if there would be an asp.net serverside(or Ajax) way to achieve this because i don't want to use more client scripts than really needed(and this is only a nice to have).

I don't believe there is any server side method to achieve what you want to. For example, the ASP.Net Page option "MaintainScrollPositionOnPostback" and the validator's "SetFocusOnError" properties all inject a small amount of javascript into a page to manage this.

If you really want to be able to scroll to the first selected item, I suggest you inherit from ListBox and add code that will inject javascript (or jQuery) to control this for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM