maintainScrollPositionOnPostBack doesn't work when i use updatePanel

3.3k Views Asked by At

I take advantage of an update panel and would like to use the ScrollPositioning but it doesn't work.

I use maintainScrollPositionOnPostBack="true" in .aspx pages.

What can I do so that it works?

2

There are 2 best solutions below

0
On BEST ANSWER

This is one of the possible sollutions taken from Personal Blog of Mustafa Başgün enter image description here https://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/

0
On

I'm using this solution (require jQuery):

<script type="text/javascript">

    var docScrollTop;
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    function BeginRequestHandler(sender, args) {
        docScrollTop= $(document).scrollTop();
    }

    function EndRequestHandler(sender, args) {
        $(document).scrollTop(docScrollTop);
    }

    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);

</script>