views:

588

answers:

2

I have one update panel inside which i have datalist.

this update panel trigger for every 1 second to retrive the data from db.

i have kept this update panel inside a vertical scroll enabled div tag.

but when i get new data. the scroller is not adjusting automatically !!!

i have tried maintainscrollback option its not working.

is there any option to maintain the scroll bar to it original position after the updatepanel triggers?

thanks in advance

+1  A: 

Please try this:

<script>
  var prm = Sys.WebForms.PageRequestManager.getInstance();
  prm.add_beginRequest(function(){
     window.dTop = document.getElementById('divIdHere').scrollTop;
  });

  prm.add_endRequest(function(){
       setTimeout(function(){
         document.getElementById('divIdHere').scrollTop = window.dTop;
      },100);
  });
</script>
jerjer
A: 

Here is what I prefer to avoid javscript, which needs to adjust scroll position each and every refresh/update...

I guess you must have designed page like below

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional/Always">
    <ContentTemplate>
     <div style="height: 400px/300px; overflow-y:scroll;"> 
      <asp:DataList ID="DataList1" runat="server">
       ....
      </asp:DataList>
     </div>
    </ContentTemplate>
</asp:UpdatePanel>

Change it to some thing like this should take care of scroll issue

<div style="height: 400px/300px; overflow-y:scroll;"> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional/Always">
     <ContentTemplate>
       <asp:DataList ID="DataList1" runat="server">
        ....
       </asp:DataList>
     </ContentTemplate>
    </asp:UpdatePanel>
</div>
in this case the scroll bar doesnt adjust to the new record added @ the bottom.
solairaja