We know that when the MaintainScrollPositionOnPostBack property of the page is True, the page automatically maintains the scroll bar position when postback.
In the previous article, "Maintaining the Panel scroll bar position", we also described how to use HiddenField to maintain the position of the Panel scroll bar, and in this article we will extend the Panel control to the same principle, making the Panel control automatically functional.
We'll inherit the Panel control and name it Tbpanel, and like Page, add a MaintainScrollPositionOnPostBack property to the Tbpanel. When MaintainScrollPositionOnPostBack is set to True, Tbpanel automatically maintains the position of the scroll bar when postback.
Tbpanel Complete program code is as follows
1Imports System
2Imports System.Collections.Generic
3Imports System.ComponentModel
4Imports System.Text
5Imports system.web
6Imports System.Web.UI
7Imports System.Web.UI.WebControls
8
9ToolboxData ("<{0}:tbpanel runat=server>") > _
10Public Class Tbpanelclass Tbpanel
One Inherits System.Web.UI.WebControls.Panel
Private Fmaintainscrollpositiononpostback as Boolean = False
13
14/**/' "
"'" Postback when automatic dimension <<