I encountered the following problem: in case of multiple ListBox selections, the scroll always goes to the top after selectedindexchanged is executed.
I used the js method written by updatepanel and jquery in the user control.
Front-end
ListBox
<Asp: listBox id = "lbresearcher" runat = "server" width = "130px" rows = "12" autopostback = "true" <br/> onselectedindexchanged = "lbresearcher_selectedindexchanged" selectionmode = "multiple" tooltip = "click" <br/> cssclass = "uc_lbresearcher"> </ASP: listBox>
JS method:
// The selected position of the scroll bar <br/> function scrollselectedheight (allcount, index) {<br/> // the total height of the scroll bar <br/> var allheight = $ (". uc_lbresearcher ") [0]. scrollheight; <br/> // The Position of the selected item In The Middle Of The ListBox <br/> $ (". uc_lbresearcher "). scrolltop (index/allcount) * allheight-$ (". uc_lbresearcher "). height ()/2); </P> <p >}< br/>
Background code
Protected void lbresearcher_selectedindexchanged (Object sender, eventargs E) <br/> {<br/> /// <br/> // function code to be processed in the background <br/> /// <br/> // locate highly executed foreground js method <br/> scriptmanager. registerstartupscript (this. page, this. page. getType (), "key", "scrollselectedheight ('" + lbresearcher. items. count + "','" + lbresearcher. selectedindex + "');", true); <br/>}
I need to improve this method. When selecting a pair, I always locate the first selected item.