After searching the web, we summarize three ways:
1. Set the MaintainScrollPositionOnPostBack property in page to True
A>: The page has MaintainScrollPositionOnPostBack, default is False, set to True (page level)
<%@ page language="C #" autoeventwireup="true" codebehind= " Default.aspx.cs " maintainscrollpositiononpostback="true" inherits= " Default.defa
Ult" %>
B>. Set the MaintainScrollPositionOnPostBack property in the Pages node in the Web. config configuration file to True (site-level or directory-level)
If you modify Web. config under the root of the site, all pages are affected, and only the Web. config file under a directory affects only the pages in that directory
Specific measures:
Configure under the <system.web> node:
<pages maintainscrollpositiononpostback="true"
C>. On the code page of the page, set the page's MaintainScrollPositionOnPostBack property to True by using C # or VB codes
true;
or write like this
This true;
2. You can use jquery to achieve the following function SetPosition () {var top=$ ("#元素id") by getting the height of the current position of an element. Offset (). Top (); $ ("Html,body"). Animate ({scrolltop:top},1000); } 3. You can use anchor points, but here you can use flexible processing to first get the ID of the position to scroll to, for example, you can set an element (<span name= "postion" id= "postion" ></SPAN> note: To be in a form), In addition, set <a href= "#postion" id= "Clicklink" in any position of the form ></a> Note: Do not have content in a tag, call in place of callback
Page.ClientScript.RegisterStartupScript (this"scroll"" document.getElementById (' Clicklink '). Click (); " true);
This method is actually the event that triggers an element
Asp. NET page refreshes and automatically scrolls to its original location