Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi!
i ma using update panel with asynchronous post back trigger but the page which is having his code doesnot work properly..i have scroll bar in this page..n when ever i scroll down it automatically scrolls up...how could i resolve this problem
XML
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                                                   <ContentTemplate>
                                                       <div id="ChatContent" runat="server" style="height: 355px; vertical-align: top; overflow-y: auto;
                                                           text-align: left; margin-left: 10px; width: 97%;">
                                                       </div>
                                                   </ContentTemplate>
                                                   <Triggers>
                                                       <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
                                                   </Triggers>
                                               </asp:UpdatePanel>
                                               <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
                                               </asp:Timer>
Posted
Comments
Sandeep Mewara 14-May-11 11:34am    
How is your async trigger related to scroll here? Why you mention it?

1 solution

I think this should work for you

Put the following script after the ScriptManager on your page. And since the _endRequest event of the PageRequestManager happens before the page is rendered, you wont see your page move

XML
<script type="text/javascript">
    var xPos, yPos;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);
    function BeginRequestHandler(sender, args) {
        xPos = $get('scrollDiv').scrollLeft;
        yPos = $get('scrollDiv').scrollTop;
    }
    function EndRequestHandler(sender, args) {
        $get('scrollDiv').scrollLeft = xPos;
        $get('scrollDiv').scrollTop = yPos;
    }
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900