Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Need help with maintaining ‘Scroll Position after Asynchronous Postback’ using AJAX

$
0
0

I am trying to maintain the ‘Scroll Position after Asynchronous Postback’ with the following piece of code

<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>

I got this code from this link: http://weblogs.asp.net/andrewfrederick/maintain-scroll-position-after-asynchronous-postback

I practically have tried everything but the code is still no working. To my surprise it is working for many people according to the link. What is it that I am doing wrong? I do have master page. Does it works with master pages? I am assuming that the ‘scrollDiv’ in the code is the ID of an Div element in the page. So, I may change it to a label, div, panel, or any other control ID. Am I right?

Please help. Thanks


Viewing all articles
Browse latest Browse all 5678

Trending Articles