title: How to maintain page scroll position after a page postback in asp.net
body: <pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"&gt;
      &lt;meta http-equiv="refresh" content="4" /&gt;   
   &lt;script type="text/javascript"&gt;
  
      var xPos1, yPos1;
  
      var prm = Sys.WebForms.PageRequestManager.getInstance();
      prm.add_pageLoading(pageLoadingHandler);
      prm.add_pageLoaded(pageLoaded);
      function pageLoaded(sender, args) {
  
          $get('&lt;%=Panel_Users.ClientID %&gt;').scrollLeft = xPos1;
          $get('&lt;%=Panel_Users.ClientID %&gt;').scrollTop = yPos1;
      }
      function pageLoadingHandler(sender, args) {
          xPos1 = $get('&lt;%=Panel_Users.ClientID %&gt;').scrollLeft
          yPos1 = $get('&lt;%=Panel_Users.ClientID %&gt;').scrollTop;
      }
      &lt;/script&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>Doesn't work, where am I going wrong</p>
  
  <p></p>
  
  <pre><code>    &lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"  /&gt;    
  
  &lt;div style="height: 504px; width: 941px;"&gt;
                   &lt;asp:Panel runat="server" ID="Panel_Users" ScrollBars="Auto" Style="z-index: 1; left: 748px;
                       top: 621px; position: absolute; height: 250px; width: 287px"&gt;
                       &lt;asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel1" runat="server"&gt;
                           &lt;ContentTemplate&gt;
                               &lt;asp:GridView ID="Grid_UserTable" runat="server" Style="z-index: 1; left: 2px; top: 5px;
                                   position: absolute; height: 152px; width: 243px" BorderColor="#666666" AutoGenerateColumns="False"
                                   OnRowDataBound="MyGrid_RowDataBound"&gt;
                                   &lt;Columns&gt;
                                       &lt;asp:TemplateField HeaderText="Status"&gt;
                                           &lt;ItemTemplate&gt;
                                               &lt;asp:Image ID="Status" runat="server" /&gt;
                                           &lt;/ItemTemplate&gt;
                                       &lt;/asp:TemplateField&gt;
                                       &lt;asp:BoundField DataField="TimeReceived" HeaderText="TimeReceived" InsertVisible="False"
                                           ReadOnly="True" SortExpression="TimeReceived" /&gt;
                                       &lt;asp:BoundField DataField="TimeRead" HeaderText="TimeRead" SortExpression="TimeRead" /&gt;
                                       &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt;
                                   &lt;/Columns&gt;
                               &lt;/asp:GridView&gt;
                           &lt;/ContentTemplate&gt;
                       &lt;/asp:UpdatePanel&gt;
                   &lt;/asp:Panel&gt;
               &lt;/div&gt;
  </code></pre>
  
  <p>I am trying to make the page stay at the same position when the page refreshes after every 5 seconds and the page goes to top. I tried Page MaintainScrollPositionOnPostback="true" . It didn't work, I tried using Ajax but have no idea how to use it. Can someone help me how to do it with Ajax. </p>