The code in ASP.net that keeps the scrollbar state in the page

  • 2020-05-12 02:27:43
  • OfStack

I looked for a lot of answers to this question on the Internet and found the answers to be confusing. In fact, the page object in Asp.net has a property that can make the page submit or update the data and return to the original position of the page, including the scrollbar position.
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" MaintainScrollPositionOnPostback="true" 
Inherits="Default.Default" %> 

Set the MaintainScrollPositionOnPostback property to true at the top of the original html page to OK;

There is also a way on the web to save the current scorll value with a hidden control. After the return pass, reset scroll according to the value of scroll.

Related articles: