Menu ▼



Posted By :
avatarmrkraju
Total Views : 3905

Maintain div or panel scroll position after postback in asp.net update panel

By default asp.net updatepanel will not maintain the div/panel scroll position after partial post back. To main the scroll position we need to add our own javascript.

Note: You need to add the below javascript code after the scriptmanager tag.

<script type="text/javascript">
    var xPos, yPos;
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    function BeginRequestHandler(sender, args) {
        if ($get('divid') != null) {
            xPos = $get('divid').scrollLeft;
            yPos = $get('divid').scrollTop;
        }
    }

    function EndRequestHandler(sender, args) {
        if ($get('divid') != null) {
            $get('divid').scrollLeft = xPos;
            $get('divid').scrollTop = yPos;
        }
    }

    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);
</script>







Search dotnetlearners.com