Keep the position unchanged after the long ASPX page is refreshed

xiaoxiao2021-04-06  301

When designing the ASP.NET page, if the page is very long, the refresh page will return directly to the top, if you want to keep the page before you refresh, add the following code in the code page, and in Page_Load ( )

Private void retainscrollPosition () {stringbuilder savescrollposition = new stringbuilder (); stringbuilder setscrollposition = new stringbuilder ();

Registerhiddenfield ("__ scrollpos", "0");

saveScrollPosition.Append ( "