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

Class PageData

Represents the content and meta data about a specific page.

Inheritance
System.Object
PageData
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 10.10.4
Syntax
[AdministrationSettings(GroupName = "pagetypes", Visible = true, Order = 10)]
public class PageData : ContentData, IInitializableContent, IReadOnly<PageData>, IReadOnly, IContentSecurable, ISecurable, IContent, IContentData, ILocalizable, ILocale, IModifiedTrackable, IVersionable, IResourceable, IChangeTrackable, IRoutable, ICategorizable, IExportable
Remarks

The PageData class contains content and meta data about a specific page. This includes the name of the page (Name), reference () and URL (LinkURL).

PageData is in many respects synonymous with the web page that it is holding properties for. One example of this is the Changed property, which holds last date and time the PageData object, in other words the web page, was changed.

Constructors

PageData()

Creates an empty PageData object.

Declaration
public PageData()

PageData(PageData)

Constructor that creates a new instance by shallow copying the state from another instance.

Declaration
public PageData(PageData copy)
Parameters
Type Name Description
PageData copy

PageData(PageReference)

Creates an empty PageData object for the given PageReference.

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

The PageReference for this page.

PageData(RawPage)

Creates an empty PageData object for the given RawPage.

Declaration
[Obsolete("No longer used, content are imported through IContentImporter and IPropertyImporter")]
public PageData(RawPage page)
Parameters
Type Name Description
RawPage page

PageData(AccessControlList, PropertyDataCollection)

Creates an empty PageData object for the given AccessControlList and PropertyDataCollection.

Declaration
public PageData(AccessControlList acl, PropertyDataCollection coll)
Parameters
Type Name Description
AccessControlList acl

Access control list

PropertyDataCollection coll

Property data collection

Properties

ACL

Gets the list of access permissions of this page. This AccessControlList describes what access certain users and roles has to this page.

Declaration
public virtual AccessControlList ACL { get; set; }
Property Value
Type Description
AccessControlList
Remarks

ACL holds the Access Control List for a PageData object. Since PageData has the attribute Property which is a PropertyDataCollection, ACL effectively controls access to the web page. Keep in mind that the Access Control List applies to all of the PageData object and its attributes. It is not possible to have different access permissions for different properties.

The Acccess Control List is comprised of an Access Control Entry, ACE, array and is accessed by calling the method ACL.ToRawACEArray.

Examples

The following code example demonstrates the usage of ToRawACEArray to enumerate the Access Control Entries. The example enumerates the RawACE objects, which together form the Access Control List and check if one of them is the Create permission.

            foreach ( EPiServer.Security.RawACE Ace in CurrentPage.ACL.ToRawACEArray() ) 
    {
        if ( ( Ace.Access & EPiServer.Security.AccessLevel.Create ) == EPiServer.Security.AccessLevel.Create ) 
        {
            // Do something
        }
    }

The following code example demonstrates the usage of QueryDistinctAccess to check specific access for the current user.

            if ( CurrentPage.ACL.QueryDistinctAccess( EPiServer.Security.AccessLevel.Create ) ) 
    {
        // Checks whether the currently logged-on user has
        // create permission for the current page.
    } 

Gets or sets a reference to a page where the page will be archived to when the StopPublish data has passed.

Declaration
public virtual PageReference ArchiveLink { get; set; }
Property Value
Type Description
PageReference

A PageReference that indicates where to archive this page when the StopPublish date has passed.

Note that the scheduled job "Archive pages" must run for the page to be archived.

Category

Gets a CategoryList containing the categories that this page belongs to.

Declaration
public virtual CategoryList Category { get; set; }
Property Value
Type Description
CategoryList

A CategoryList with the categories.

Remarks

This is used to determine which categories that the page belongs to, it should not be confused with a property of type PropertyCategory defined on the page type.

If there is no "PageCategory" property, a null object will be returned.

Changed

Gets the date when this page was last marked as changed.

Declaration
public virtual DateTime Changed { get; set; }
Property Value
Type Description
System.DateTime
Remarks

The changed date is only updated when property PageChangedOnPublish is set to true.

Examples

The following code example demonstrates the usage of Changed.

string changedDateTime = CurrentPage.Changed.ToString( "r" ); 

ChangedBy

Gets the username of the user that most recently changed this page.

Declaration
public virtual string ChangedBy { get; set; }
Property Value
Type Description
System.String
Remarks

For instance, if a Windows account was used to create the page, expect a string being returned looking like 'DOMAIN\User Name'.

Examples
  The following code example demonstrates the usage of <strong>ChangedBy</strong>.
    Page changed by: <%# CurrentPage.ChangedBy %>

ContentAssetsID

Gets or sets the content folder ID.

Declaration
public virtual Guid ContentAssetsID { get; set; }
Property Value
Type Description
System.Guid

ContentGuid

Gets or sets the content GUID.

Declaration
public virtual Guid ContentGuid { get; set; }
Property Value
Type Description
System.Guid

Gets or sets the content link. It used to hold references to content in the EPiServer system.

Declaration
public virtual ContentReference ContentLink { get; set; }
Property Value
Type Description
ContentReference

The content link.

ContentTypeID

Gets or sets the content type ID that this ContentData is an instance of.

Declaration
public virtual int ContentTypeID { get; set; }
Property Value
Type Description
System.Int32

Created

Gets the date and time when this content instance was created.

Declaration
public virtual DateTime Created { get; set; }
Property Value
Type Description
System.DateTime
Remarks

Created is maintained by the EPiServer infrastructure and you have no control over them.

CreatedBy

Gets the username of the user that created this content instance.

Declaration
public virtual string CreatedBy { get; set; }
Property Value
Type Description
System.String

Deleted

Gets a value indicating when the page has been deleted.

Declaration
public virtual DateTime? Deleted { get; set; }
Property Value
Type Description
System.Nullable<System.DateTime>

Date of deletion.

DeletedBy

Gets a value indicating who deleted the page.

Declaration
public virtual string DeletedBy { get; set; }
Property Value
Type Description
System.String

Deleted by.

ExistingLanguages

Gets or sets the existing langauges for this instance.

Declaration
public virtual IEnumerable<CultureInfo> ExistingLanguages { get; set; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Globalization.CultureInfo>

The existing langauges.

ExternalURL

Gets or sets the page's external URL.

Declaration
public virtual string ExternalURL { get; set; }
Property Value
Type Description
System.String

IsDeleted

Gets a value indicating if the page has been deleted. It is marked as deleted if it resides in the wastebasket.

Declaration
public virtual bool IsDeleted { get; set; }
Property Value
Type Description
System.Boolean

true if the page is in the wastebasket, otherwise false

Remarks

Since a deletion of a page moves the page to wastebasket rather than deleting it directly, you can use this property to check if the page is deleted or if it is live.

IsMasterLanguageBranch

Gets a value indicating if the current page is the master language branch.

Declaration
public virtual bool IsMasterLanguageBranch { get; }
Property Value
Type Description
System.Boolean

IsModified

Gets or sets a value indicating whether this instance has been modified after loading.

Declaration
public bool IsModified { get; set; }
Property Value
Type Description
System.Boolean

True if this instance has been modified, otherwise false.

Remarks

The setter will only work to reset the modified state (that is, setting it to false). Avoid using the setter altogether and use ResetModified() instead.

IsPendingPublish

Gets or sets a value indicating whether this instance is in pending publish state.

Declaration
public virtual bool IsPendingPublish { get; set; }
Property Value
Type Description
System.Boolean

True if this instance is in pending publish state; otherwise, false.

Language

Gets or sets the language for this instance.

Declaration
public virtual CultureInfo Language { get; set; }
Property Value
Type Description
System.Globalization.CultureInfo

The language.

LanguageBranch

Gets or sets the ID of the language branch of this page.

Declaration
[Obsolete("Use ILocalizable.Language instead")]
public virtual string LanguageBranch { get; }
Property Value
Type Description
System.String

The language branch ID or null if not set.

LanguageID

Gets or sets the ID of the language branch of this page.

Declaration
[Obsolete("Use ILocalizable.Language instead")]
public virtual string LanguageID { get; set; }
Property Value
Type Description
System.String

The language branch ID or an empty string if not set.

LinkType

Gets or sets the type of URL that should be used for this page.

Declaration
public virtual PageShortcutType LinkType { get; set; }
Property Value
Type Description
PageShortcutType

LinkURL

Gets or sets the URL to this page.

Declaration
public virtual string LinkURL { get; set; }
Property Value
Type Description
System.String
Remarks

The LinkURL string property contains root-relative path and query of the URL for the page, in other words to get an absolute URL, prepend LinkURL with the appropriate scheme and host.

MasterLanguage

Gets or sets the master language for this instance.

Declaration
public virtual CultureInfo MasterLanguage { get; set; }
Property Value
Type Description
System.Globalization.CultureInfo

The master language.

MasterLanguageBranch

Gets or sets the ID of the master language branch for this page.

Declaration
[Obsolete("Use ILocalizable.MasterLanguage instead")]
public virtual string MasterLanguageBranch { get; set; }
Property Value
Type Description
System.String

The language branch ID or null if not set.

Name

Gets or sets the name of the page.

Declaration
public virtual string Name { get; set; }
Property Value
Type Description
System.String

PageFolderID

Gets the identifier for the document folder associated with this page.

Declaration
[Obsolete("Only used by old Virtual Path Providers")]
public virtual int PageFolderID { get; }
Property Value
Type Description
System.Int32

PageGuid

Gets or sets the unique System.Guid based identifier for the page.

Declaration
[Obsolete("Use ContentGuid instead")]
public virtual Guid PageGuid { get; set; }
Property Value
Type Description
System.Guid

PageLanguages

Gets the available languages for the page.

Declaration
[Obsolete("Use ILocalizable.ExistingLanguages instead")]
public virtual ReadOnlyStringList PageLanguages { get; }
Property Value
Type Description
ReadOnlyStringList

The page languages.

Gets or sets the unique PageReference identifier of the current page.

Declaration
public virtual PageReference PageLink { get; set; }
Property Value
Type Description
PageReference

The use of PageLink is derived from the way in which EPiServer is structured. Pages are nothing more than an instance of an EPiServer page type and a collection of property settings stored in the database. Individual pages are identified by the pkID column in the database table tblPage and transforming this into a URL, you get something looking like "templates/emailpagecontainer.aspx?id=n?", where "n" is the previously mentioned pkID and thus the unique page identifier.

The following example demonstrates the usage of PageLink in HTML.

As PageLink is guaranteed to be unique among all pages in a certain EPiServer instances, it is used in the following example to create unique IDs and names for HTML check boxes. The code is used to present the visitor with a selection of pages and allows them to select one or more for further processing.

    <EPiServer:PageList SortBy="PageName" DataSource="<%#PropertySearchControl%>" runat="server" ID="PageListControl">
<ItemTemplate>
    ...
    <input type="checkbox" id="ViewUser<%#Container.CurrentPage.PageLink%>" name="ViewUser<%# Container.CurrentPage.PageLink %>" />
    ...
</ItemTemplate>
</EPiServer:PageList>

PageName

Gets or sets the display name of page.

Declaration
public virtual string PageName { get; set; }
Property Value
Type Description
System.String
Remarks

Not many page settings are under absolute editor control, but PageName is one of them. PageName is a descriptive name given the page in Edit mode. PageName can be used to great benefit in many cases, such as templated controls.

Examples

The following example demonstrates the usage of PageName and LinkURL. The HTML code below produces two HTML table rows for every news item page displayed. The first row displays the content of the property PageStartPublish and the second row is an HTML anchor tag, where PageData.LinkURL is the relative URL for the page and PageData.PageName is used as a new headline. Note that PageData.Item is used twice in this HTML code, as the two attributes PageStartPublish and MainIntro are accessed using the indexer for the PageData property.

    <EPiServer:Newslist ID="Newslistnew" Pagelinkproperty="NewsContainer" runat="server" MaxCount='<%# GetNewsCount() %>'>
<NewsTemplate>
    <tr>
        <td class="DateListingText"><%# Container.CurrentPage[ "PageStartPublish" ] %></td>
    </tr>
    <tr>
        <td>
            <a href="<%# Container.CurrentPage.LinkURL %>" class="StartPageHeading">
            <%# Container.CurrentPage.PageName %></a>&nbsp;<br />
            <span class="Normal">
            <%# Container.CurrentPage[ "MainIntro" ] %>
            </span>
        </td>
    </tr>
</NewsTemplate>
</EPiServer:Newslist>    

PageTypeID

Gets or sets the id of the PageType used to create this page.

Declaration
[Obsolete("Use ContentTypeID")]
public virtual int PageTypeID { get; set; }
Property Value
Type Description
System.Int32
Remarks

PageTypeID is the same as column fkPageTypeID in the database table tblPage.

PageTypeName

Gets or sets the name of the PageType used to create this page.

Declaration
public virtual string PageTypeName { get; set; }
Property Value
Type Description
System.String

A string with the name.

Remarks

This is the page type name as entered in Admin mode. It will not be translated in any way. PageTypeName is the same as column Name in the database table tblPageType.

Gets or sets a reference to the page that is the closest parent of this page.

Declaration
public virtual PageReference ParentLink { get; set; }
Property Value
Type Description
PageReference

Parent and childhood is determined by placement in the page tree.

In the following code example ParentLink is used twice. First make sure it contains a non-empty PageReference and secondly to retrieve the sibling of the current page.

            if ( CurrentPage.ParentLink != EPiServer.Core.PageReference.EmptyReference ) 
    {
        EPiServer.Core.PageDataCollection siblings = GetChildren( CurrentPage.ParentLink );
    } 

The following code example demonstrates the usage of ParentLink. The example results in the name of the parent page being displayed.

    Parent Page Name: <%= GetPage( CurrentPage.ParentLink ).PageName %>     

PendingArchive

Gets a value indicating if this page is pending archiving and should be moved to its archive folder.

Declaration
public virtual bool PendingArchive { get; }
Property Value
Type Description
System.Boolean

True if the page should be archived now.

Remarks

This is a utility property that checks if the page has an archive folder and its StopPublish date has passed.

PendingPublish

Gets a value indicating if this page is pending publishing.

Declaration
public virtual bool PendingPublish { get; set; }
Property Value
Type Description
System.Boolean

Saved

Gets the date and time when this page was last saved.

Declaration
public virtual DateTime Saved { get; set; }
Property Value
Type Description
System.DateTime
Remarks

Saved is the sibling of Created and is maintained by the EPiServer infrastructure. This means that you have no control over them.

SetChangedOnPublish

Gets or sets a value indicating whether the Changed should be updated on publish.

Declaration
public virtual bool SetChangedOnPublish { get; set; }
Property Value
Type Description
System.Boolean

True if Changed should be updated, otherwise false.

ShouldBeImplicitlyExported

Gets a value indicating whether this instance should be implicitly added to export package when referenced by some entity that is exported.

Declaration
protected virtual bool ShouldBeImplicitlyExported { get; }
Property Value
Type Description
System.Boolean

True if the instance should implicity be added to export package when referenced, otherwise false.

Remarks

Default implementation returns false.

StartPublish

Gets the date and time when this page will be published.

Declaration
public virtual DateTime? StartPublish { get; set; }
Property Value
Type Description
System.Nullable<System.DateTime>

StaticLinkURL

Gets or sets the URL to this page as stored in the database.

Declaration
public virtual string StaticLinkURL { get; set; }
Property Value
Type Description
System.String

Status

Gets the editing status of the current version.

Declaration
public virtual VersionStatus Status { get; set; }
Property Value
Type Description
VersionStatus

The status.

StopPublish

Gets or sets the date and time when this page will stop to be published.

Declaration
public virtual DateTime? StopPublish { get; set; }
Property Value
Type Description
System.Nullable<System.DateTime>

TargetFrameName

Get the specified target frame for links to this page

Declaration
public virtual string TargetFrameName { get; }
Property Value
Type Description
System.String

URLSegment

Gets or sets the segment that represents this page in an URL.

Declaration
public virtual string URLSegment { get; set; }
Property Value
Type Description
System.String

VisibleInMenu

Gets or sets a value indicating whether this page should be visible in menus and tree structures.

Declaration
public virtual bool VisibleInMenu { get; set; }
Property Value
Type Description
System.Boolean
Remarks

Setting VisibleInMenu to false is way to hide a page so that it will not be displayed in conjunction with other sibling items in the tree, which would otherwise happen automatically. It is typically filtered by, or close to, the presentation layer.

VisibleInMenu is stored in the column VisibleInMenu in database table tblContent.

WorkPageID

Gets or sets the identifier of the current version of this page.

Declaration
public virtual int WorkPageID { get; set; }
Property Value
Type Description
System.Int32

An System.Int32 representing the version ID.

Remarks

Note that the current implementation of WorkPageID will be strictly increasing with later versions, but you should avoid relying on this aspect and just treat WorkPageID as an opaque identity without any implied semantics.

Methods

CheckPublishedStatus(PagePublishedStatus)

Indicates whether the page should be displayed based on publish date.

Declaration
public bool CheckPublishedStatus(PagePublishedStatus status)
Parameters
Type Name Description
PagePublishedStatus status

The type of publish status to check against.

Returns
Type Description
System.Boolean

True if the page should be displayed.

Remarks

Used internally to filter pages in listings. You should usually not need to refer to this method directly.

Copy()

Creates a deep copy of the current object, as opposed to a shallow copy.

Declaration
public PageData Copy()
Returns
Type Description
PageData

A new PageData.

Remarks

In most cases you will probably want to use the new CreateWritableClone() method instead, since copying a read-only instance will return a new read-only instance.

This method performs a deep copy and the copy should therefore have no references to the original PageData instance. This is to say that you can freely modify the copy without altering the original.

CreateWritableClone()

Creates a writable clone of this object.

Declaration
public PageData CreateWritableClone()
Returns
Type Description
PageData

A writable PageData object.

CreateWriteableCloneImplementation()

Creates a writable clone of this object.

Declaration
protected override object CreateWriteableCloneImplementation()
Returns
Type Description
System.Object

A clone of this object that is writable.

Overrides
Remarks

This method is called by CreateWritableClone(). If you are inheriting, directly or indirectly, from ContentData you should override this method to make sure that all reference type members of your class are cloned.

Your override of this method must create the clone by calling base.CreateWritableCloneImplementation(). This ensures that all classes in the inheritance chain can create clones as necessary. Also, by calling the base implementation the values of all value type members are copied as the ContentData implementation of this method calls System.Object.MemberwiseClone().

GetContentSecurityDescriptor()

Gets the security descriptor.

Declaration
public virtual IContentSecurityDescriptor GetContentSecurityDescriptor()
Returns
Type Description
IContentSecurityDescriptor

An implementation of ISecurityDescriptor.

GetSecurityDescriptor()

Gets the security descriptor.

Declaration
public virtual ISecurityDescriptor GetSecurityDescriptor()
Returns
Type Description
ISecurityDescriptor

An implementation of ISecurityDescriptor.

InitializeData(IList<String>)

Initializes the page with available page languages.

Declaration
public virtual void InitializeData(IList<string> pageLanguages)
Parameters
Type Name Description
System.Collections.Generic.IList<System.String> pageLanguages

MakeReadOnly()

Protects from modifying this object.

Declaration
public override void MakeReadOnly()
Overrides

PopulateDynamicProperties()

This method is not used by the framework anymore and has been deprecated.

Declaration
[Obsolete("Not used by the EPiServer Framework any more", true)]
public void PopulateDynamicProperties()

SetDefaultValues(ContentType)

Sets the default property values on the page data.

Declaration
public override void SetDefaultValues(ContentType contentType)
Parameters
Type Name Description
ContentType contentType

The type of content.

Overrides
Examples
[ContentType(DisplayName = "Article Page")]
public class Article : PageData
{
public virtual string Heading { get; set; }
public virtual XhtmlString MainBody { get; set; }

public override void SetDefaultValues(ContentType pageType)
{
    base.SetDefaultValues(pageType);

    Heading = "My awesome article";
    MainBody = new XhtmlString("<p>Enter your article text here<p/>");
}
}

ShallowCopy(PageData)

Shallow copies the state of the passed PageData instance.

Declaration
protected virtual void ShallowCopy(PageData copy)
Parameters
Type Name Description
PageData copy

The instance to copy state from.

ToRawPage()

Returns the current instance converted to a RawPage object.

Declaration
public RawPage ToRawPage()
Returns
Type Description
RawPage

A RawPage.

Remarks

Used primarily by the DataFactory Web Service to transfer PageData instances to web service clients.

Explicit Interface Implementations

Gets or sets the parent link. It used to hold references to the parent content in the EPiServer system.

Declaration
ContentReference IContent.ParentLink { get; set; }
Returns
Type Description
ContentReference

The parent link.

IModifiedTrackable.IsModified

Gets a value indicating whether this instance has been modified after loading.

Declaration
bool IModifiedTrackable.IsModified { get; }
Returns
Type Description
System.Boolean

True if this instance has been modified, otherwise false.

IModifiedTrackable.ResetModified()

Resets the modified flag on all the properties in the Property collection.

Declaration
void IModifiedTrackable.ResetModified()

IVersionable.StartPublish

Gets or sets the start publish.

Declaration
DateTime? IVersionable.StartPublish { get; set; }
Returns
Type Description
System.Nullable<System.DateTime>

The start publish.

IVersionable.StopPublish

Gets the date and time when this page will stop to be published.

Declaration
DateTime? IVersionable.StopPublish { get; set; }
Returns
Type Description
System.Nullable<System.DateTime>

The stop publish.

Remarks

This date will be set to System.DateTime.MaxValue if no specific stop publish date has been set.

IExportable.ShouldBeImplicitlyExported

Gets a value indicating whether this instance should be implicitly added to export package when referenced by some entity that is exported.

Declaration
bool IExportable.ShouldBeImplicitlyExported { get; }
Returns
Type Description
System.Boolean

True if the instance should implicity be added to export package when referenced, otherwise false.

IRoutable.RouteSegment

Gets or sets the Route segment.

Declaration
string IRoutable.RouteSegment { get; set; }
Returns
Type Description
System.String

The Route segment.

Implements

Extension Methods