Scroll Page form After submitting the page resone back to the original scroll bar location

xiaoxiao2021-03-05  24

Author

Scottwater original address:

http://scottwater.com/articles/scrollpage

thank

Mr. Scottwater!

I made a little modification to support the memory of the horizontal scroll bar position.

Disclaimer

#Region disclaimer / ** // ************************************************************ ********************************************* BASEDOMABE OF INFRAGISTISUPDATED by Scott Watermasysk (http://scottwater.com) Provided AS IS, WITH NO WARRENTY, ETC.PLEASE USE HOWEVER YOU SEE FIT. JUST DON't Ask for a VB Version:) ********************************* ***************************************************************************************************************************************************************************************************************************************************************************************************** / # endregion

Using

System;

Using

System.IO;

Using

System.Text;

Using

System.Text.RegularExpress;

Using

System.Web.ui;

Namespace

Shanggu.xataxi.components

{/ ** ////

/// Summary description for ScrollPage /// public class ScrollPage: System.Web.UI.Page {public ScrollPage () {} private bool _useScrollPersistence = true;. / ** //// /// There Could Be Postback Senarios Where We do Not Want To Remember The Scroll Position. Set this property to false /// if you would like the page to forget the current scroll position / // public bool UseScrollPersistence {get {return this._useScrollPersistence;} set {this._useScrollPersistence = value;}} private string _bodyID; / ** //// /// Some pages might already have the ID attribute set for the body tag. Setting this property will not render the ID or change /// the existing value. It will simply update the javascript written out to the browser. /// public string BodyID { get {return this._bodyID;} set {this._bodyID = value;}} // Last chance Do we want to maintain the current scroll position protected override void OnPreRender (EventArgs e) {if (UseScrollPersistence) {RetainScrollPosition ().; } base.OnPreRender (e);} protected override void Render (HtmlTextWriter writer) {// No need processing the HTML if the user does not want to maintain scroll position or already has // set the body ID value if (UseScrollPersistence) { TextWriter Tempwriter = new stringwriter ();

Base.Render (New HtmlTextWriter); if (bodyid == null) {Writer.write (Tempwriter.Tostring (), "

// // 2004-9-20 武眉 博 increases hidden text domain "__scrollpos_left" to increase the memory function of the horizontal scroll bar position / / / = Private STATIC STRING SAVESCROLLPSITION = "