Search code examples
ajaxupdatepanelscrollbarasynchronous-pages

Ajax update panel scroll bar issue


I have one update panel inside which I have datalist.

This update panel triggers every 1 second to retrieve the data from db.

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

But when I get new data, the scroll bar is not adjusting automatically !!!

I have tried maintainscrollback option but its not working.

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


Solution

  • Here is what I prefer to avoid JavaScript, 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>