Friday 14 October 2016

Maintain Panel Scroll Position On Partial Postback ASP.NET




<script type="text/javascript">
            // It is important to place this JavaScript code after ScriptManager1
            var xPos, yPos; // Set X and Y positions
            var prm = Sys.WebForms.PageRequestManager.getInstance();

            function BeginRequestHandler(sender, args) {
                if ($get('<%=pnl_memgrid.ClientID%>') != null) {
                    // Get X and Y positions of scrollbar before the partial postback
                    xPos = $get('<%=pnl_memgrid.ClientID%>').scrollLeft;
                    yPos = $get('<%=pnl_memgrid.ClientID%>').scrollTop;
                }
            }

            function EndRequestHandler(sender, args) {
                if ($get('<%=pnl_memgrid.ClientID%>') != null) {
                    // Set X and Y positions back to the scrollbar
                    // after partial postback or full post back
                    $get('<%=pnl_memgrid.ClientID%>').scrollLeft = xPos;
                    $get('<%=pnl_memgrid.ClientID%>').scrollTop = yPos;
                }
            }

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

 </script>

No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...