c# - ASP.Net Listbox: maintain listbox scrolling position after partial postback (not site scrolling position!) -


on asp.net page have listbox. when selected items in changes, dropdownlist gets activated or deactivated depending on item, , again depending on listbox item item in dropdownlist selected.

i can't onselecteditemchanged action of listbox in javascript because need query 2 different databases action.

the problem have whenever there partial postback on site selection changed event in listbox, selected listbox item scrolls top (in ie) or bottom (in chrome) of listbox. extremely irritating user.

here's how listbox looks before user selects itementer image description here:

now user selects item, eventhandler selectionchanged gets called, fills dropdownlist below data, , partial postback occurs. example user clicks "klärschlamm" item in listbox, 4th one. after postback listbox looks like:

enter image description here

suddenly selected item on top of listbox instead of bottom when selected.

what can maintain scrolling position of listbox after postback? tried lot of "solutions" i've found on net, wrapping listbox , dropdown in updatepanels, using javascript begin- , endrequesthandlers, etc. none of solutions i've found changed anything, alas.

here's xaml use:

<%@ page title="" language="c#" masterpagefile="~/site.master"  autoeventwireup="true" codebehind="abfalledit.aspx.cs" %>  <asp:updatepanel runat="server" updatemode="always" childrenastriggers="true">   <contenttemplate>     <asp:listbox id="list" clientidmode="static" runat="server" autopostback="true"      onselectedindexchanged="updatekontamination" />   </contenttemplate> </asp:updatepanel>  <asp:updatepanel runat="server">   <contenttemplate>     <asp:dropdownlist id="drop" runat="server" />   </contenttemplate> </asp:updatepanel> 

the selectedindexchanged event handler nothing database queries , activating dropdownlist , setting respective index. doesn't listbox itself. , databind listbox if it's not postback.

this post pretty old in case else having same issue...

change markup

    <asp:updatepanel id="uplist" runat="server" updatemode="conditional">        <triggers>         <asp:asyncpostbacktrigger controlid="othercontroltoupdatelist" eventname="<eventname>" />       </triggers>             <contenttemplate>          <asp:listbox id="list" clientidmode="static" runat="server" autopostback="true"              onselectedindexchanged="updatekontamination" />       </contenttemplate>     </asp:updatepanel>      <asp:updatepanel id="updrop" runat="server" updatemode="conditional">       <triggers>         <asp:asyncpostbacktrigger controlid="list" eventname="selectedindexchanged" />       </triggers>       <contenttemplate>         <asp:dropdownlist id="drop" runat="server" />       </contenttemplate>     </asp:updatepanel> 

this should keep "uplist" firing , rebuilding "list" on selection change.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -