4

When I am clicking on any button my page is re loading and page position is getting change.

first page is scrolling bottom then going on top again its moving to down side.

How could I retain the scroll position same after page refresh on any event click.

I tried

Page.MaintainScrollPositionOnPostBack = true;

on my page load but its not working.

I used ajax updatepanel after using it my browser is getting stuck, and performance is very slow.

I have one aspx page, in that i am calling 5 web user control.

Please any one help me..

How could I retain the scroll position same after page refresh on any event click.

codingbadger
  • 40,660
  • 13
  • 93
  • 109
Rocky
  • 4,344
  • 12
  • 62
  • 116

3 Answers3

2

Did you tried declaratively setting MaintainScrollPositionOnPostBack property on your page ,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs"
    Inherits="test" MaintainScrollPositionOnPostback="true" %>
DSharper
  • 3,137
  • 9
  • 28
  • 46
1

Have look into this article Maintain Scroll Position after Asynchronous Postback

and check this thread Reset scroll position after Async postback - ASP.NET

Community
  • 1
  • 1
Muhammad Akhtar
  • 51,472
  • 37
  • 135
  • 186
0

I used update panel as well as this script and its working well for me..

 <script>
    var xPos, yPos;
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_beginRequest(BeginRequestHandler);
    prm.add_endRequest(EndRequestHandler);
    function BeginRequestHandler(sender, args) {
        xPos = document.getElementById("<%=Panel4.ClientID %>").scrollLeft;
        yPos = document.getElementById("<%=Panel4.ClientID %>").scrollTop;
    }
    function EndRequestHandler(sender, args) {
        document.getElementById("<%=Panel4.ClientID %>").scrollLeft = xPos;
        document.getElementById("<%=Panel4.ClientID %>").scrollTop = yPos;
    }
 </script>
Rocky
  • 4,344
  • 12
  • 62
  • 116