Click here to Skip to main content
15,898,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello
I have a multiline textbox with horizontal scroll bar.
And have a timer that will get data from database every 3 seconds, my problem is: every time the timer get data from database the position of the scrollbar will be moved, What Can I Do?,
I would be gratitude answer me
Posted

As an alternative, place the following script after the ScriptManager on your page. And since the _endRequest event of the PageRequestManager happens before the page is rendered, you’ll never even see your item 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
 
Comments
SinaNadi 10-Mar-12 9:33am    
Thanks a lot
Try the declaratively setting MaintainScrollPositionOnPostBack property on your page as:

ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs"     Inherits="test" MaintainScrollPositionOnPostback="true" %>
 
Share this answer
 
v2

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