This topic has not yet been rated - Rate this topic

SPRememberScroll Class

Wraps controls that need scroll bars, and remembers the scroll position between postbacks.

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      System.Web.UI.WebControls.Panel
        Microsoft.SharePoint.WebControls.SPRememberScroll

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SPRememberScroll : Panel

This control is specialized for SPTreeView and is therefore not generically reusable.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
SPRememberScroll
Description

The Microsoft.SharePoint.WebControls.SPRememberScroll class inherits from the System.Web.UI.WebControls.Panel class since SPRememberScroll acts as a placeholder for childern controls. However, unlike a Panel control SPRememberScroll is commonly employed for one control rather than grouping related controls. To handle the scrolling position persistence for controls within SharePoint, it is possible to add them to the SPRememberScroll control collection for rendering.

The SPRememberScroll class functions by placing relevant display attributes, namely "ScrollTop" and "ScrollLeft" on the Page object. These can subsequently be called out and through the use of JavaScript functions, maintaining scrolling position when leveraging particular controls.

Usage Scenario

The ordinary usage for the SPRememberScroll control is with navigational elements since they contain user mutable elements, the most common in SharePoint development being the SPTreeView control. 

Because of the inheritance of SPRememberScroll from Panel, it can be treated as an orthodox Panel control. When developing a composite control, a new SPRememberScroll object can be hydrated, a control added to the SPRememberScroll.Controls collection, and then added to the current instance control collection for rendering. 

In the below, a new SPRememberScroll object is being created and its ID property being set. Following a new SPTreeView object is created, its ID and DataSourceID property set, which is added to the SPRememberScroll.Controls collection. Lastly, the SPRememberScroll object is added to the current instance control collection.

C# Code Example

protected override void CreateChildControls()
{
SPRememberScroll scroll = new SPRememberScroll();
scroll.ID = "Scroller";
SPTreeView view = new SPTreeView();
view.ID = "MyWebTreeView";
view.DataSourceID = "MyDataSourceId";
scroll.Controls.Add(view);
base.CreateChildControls();
}

VB.NET Code Example

Protected Overloads Overrides Sub CreateChildControls()
Dim scroll As New SPRememberScroll()
scroll.ID = "Scroller"
Dim view As New SPTreeView()
view.ID = "MyWebTreeView"
view.DataSourceID = "MyDataSourceId"
scroll.Controls.Add(view)
MyBase.CreateChildControls()
End Sub

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com