November Happy Hour will be moved to Thursday December 5th.

Interface IPageSource

Interface for providers of PageData objects.

Namespace: EPiServer.Core
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public interface IPageSource

Properties

CurrentPage

Gets the currently loaded PageData.

Declaration
PageData CurrentPage { get; }
Property Value
Type Description
PageData

Returns information about the currently loaded page, or a page in a collection when used inside a control.

Remarks

The implementation of CurrentPage is strictly up to the implementing class. Some of the templated Web controls implement IPageSource, and CurrentPage will typically refer to the current page being iterated in a collection or an array.

Another implementor is the PageBase class or one of it's subclasses like SimplePage or TemplatePage. CurrentPage in the context of PageBase refers to the currently displayed page.

CurrentPage may be null on sources that aren't connected through PageBase.

Examples

The following code example demonstrates the usage of CurrentPage.

Response.Write(CurrentPage.PageName); 

Methods

GetChildren(PageReference)

Retrieve a PageData listing

Declaration
PageDataCollection GetChildren(PageReference pageLink)
Parameters
Type Name Description
PageReference pageLink

Reference to parent page

Returns
Type Description
PageDataCollection

Returns a collection of pages directly below the page referenced by the PageReference parameter.

Examples
  The following code example demonstrates the usage of <strong>GetChildren</strong>.
            IContentRepository factory =  DataFactory.Instance;
PageReference parent = PageReference.StartPage; 
IEnumerable<PageData> pages = factory.GetChildren<PageData>(parent);
Response.Write("Count of pages: " + pages.Count());

GetPage(PageReference)

Retrieves a PageData object with information about a page, based on the PageReference parameter.

Declaration
PageData GetPage(PageReference pageLink)
Parameters
Type Name Description
PageReference pageLink

Reference to the page being retrieved

Returns
Type Description
PageData

PageData object requested

Examples
  The following code example demonstrates how to get a start page.
            IContentRepository factory = DataFactory.Instance;
PageData page = factory.Get<PageData>(PageReference.StartPage);
Response.Write(page.PageName);
        The following code example demonstrates how to get a page by ID.
            IContentRepository factory = DataFactory.Instance;
PageData page = factory.Get<PageData>(new PageReference(30));
Response.Write(page.PageName);

Extension Methods