Try our conversational search powered by Generative AI!

Class Property

WebControl for rendering page properties.

Inheritance
System.Object
Property
Namespace: EPiServer.Web.WebControls
Assembly: EPiServer.Web.WebControls.dll
Version: 11.20.7
Syntax
public class Property : WebControl, INamingContainer, IPageSource, IPageControl, IContentControl, IContentSource, IPropertyControlsContainer
Remarks

The Property control is used on web forms and user controls and renders the value of built-in or custom properties to the HTML stream.

Examples
  The following example shows how to print the name of the page to HTML:
    <EPiServer:Property PropertyName="PageName" runat="server" />
note

        The PropertyName attribute is not case sensitive.

For the Property control to be able to read the properties from the page, it needs to be hosted on a web form or a control that implements the IPageSource interface. The control will iterate through the control hierarchy looking for this interface, and when it finds one it will use the CurrentPage property to read the information about the specific built-in or custom property.

If you put a Property control inside a templated control like the PageList control, that implements IPageSource, the Property control will use the CurrentPage property of the template control instead. The PageList then points the Property control to the current PageData object in its internal PageDataCollection. This is why the two following PageList examples will print the same:

    <EPiServer:PageList PageLink="<%# EPiServer.Core.PageReference.StartPage%>" runat="server">
<ItemTemplate>
<EPiServer:Property PropertyName="PageName" runat="server" />
</ItemTemplate>
</EPiServer:PageList>

<EPiServer:PageList PageLink="<%# EPiServer.Core.PageReference.StartPage%>" runat="server"> <ItemTemplate> <%#Container.CurrentPage.PageName%> </ItemTemplate> </EPiServer:PageList>

You can also access the inner PropertyData object through the InnerProperty property, if you need access to the raw value.

Constructors

Property()

Initializes a new instance of the Property class.

Declaration
public Property()
Remarks

This control requires that either the PropertyName or the InnerProperty property is set for it to work properly.

Property(PropertyData)

Initializes a new instance of the Property class with the given PropertyData instance.

Declaration
public Property(PropertyData propertyData)
Parameters
Type Name Description
PropertyData propertyData

The inner property data object.

Properties

BoundPageID

Gets the ID of the PageData instance bound to the current template container.

Declaration
protected int BoundPageID { get; }
Property Value
Type Description
System.Int32

ContentSource

Gets or sets the content source.

Declaration
public virtual IContentSource ContentSource { get; set; }
Property Value
Type Description
IContentSource

The content source.

ContextBuilder

Gets or sets the ControlRenderContextBuilder that should be used by the current control instance.

Declaration
protected Injected<ControlRenderContextBuilder> ContextBuilder { get; set; }
Property Value
Type Description
Injected<ControlRenderContextBuilder>

CssClass

Declaration
public override string CssClass { get; set; }
Property Value
Type Description
System.String

CurrentContent

Gets the currently loaded IContent.

Declaration
public IContent CurrentContent { get; }
Property Value
Type Description
IContent

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

CurrentContext

Gets the current render context of this control instance. This will not be available until the control has been added to the control tree.

Declaration
protected virtual PropertyContext CurrentContext { get; }
Property Value
Type Description
PropertyContext

CustomTagName

Gets or sets the tag name. If not set a span-tag will be used.

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

The custom tag name.

Examples

Set to "h1" to create a h1-tag around the content.

DisplayMissingMessage

Gets or sets a value indicating if an error message should be displayed if no property with the name provided by PropertyName could be found.

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

If the property pointed to by PropertyName does not exist, an error message will be printed instead. If you want to suppress this error message, set this property to false.

<episerver:property propertyname="MyProperty" runat="server" DisplayMissingMessage='false' />

Editable

Controls if the property is editable with DOPE

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

The Property control will give you DOPE (Direct On Page Editing) support if the underlaying template page supports it (any web form that inherits directly or indirectly from TemplatePage. If you do not want DOPE support you can either inherit from SimplePage, or set the Editable property to false, like this:

<episerver:property propertyname="PageName" runat="server" Editable='false' />

EditMode

Controls if the property should render it's edit mode.

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

By setting the EditMode property to true the property will be rendered in "edit view", just like it is when viewed through the Editors View.

note

Note: Any changes to the edit control will be saved if you enter DOPE mode on the page and save it, or call the OnDopeSave() client side method from client side script.

<episerver:property editmode="True" runat="server" propertyname="MainBody" /> 
<button onclick="OnDopeSave()">Save</button>

EditorSettings

Gets or sets any editor settings for the property.

Declaration
public virtual PropertyEditorSettings EditorSettings { get; }
Property Value
Type Description
PropertyEditorSettings

The editor settings for the property.

Remarks

These settings can vary from property to property, consult the documentation for each property for more details on custom properties.

InnerProperty

Set or get the inner property used by this control

Declaration
public virtual PropertyData InnerProperty { get; set; }
Property Value
Type Description
PropertyData

ObjectSerializerFactory

Gets or sets the object serializer to use when serializing to Json.

Declaration
protected Injected<IObjectSerializerFactory> ObjectSerializerFactory { get; set; }
Property Value
Type Description
Injected<IObjectSerializerFactory>

The object serializer.

OverlaySettings

Gets or sets any overlay settings for the property.

Declaration
public virtual PropertyEditorSettings OverlaySettings { get; }
Property Value
Type Description
PropertyEditorSettings

The overlay settings for the property.

Remarks

These settings can vary from property to property, consult the documentation for each property for more details on custom properties.

The root page to read data from if different from current

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

If you do not want the Property web control to retrieve the property value from the currently loaded page (or the current page in a PageDataCollection when inside a templated web control) you can set the PageLink to point to another page.

The PageLink property is a PageReference, but you can also assign an int (the ID of the page.)

<episerver:property runat="server" propertyname="MainBody" PageLink="30" />

or:

<episerver:property runat="server" propertyname="MainBody" PageLink='<%# EPiServer.Global.EPConfig.StartPage%>' />

PageLinkProperty

The property that contains the root page to read data from if different from current

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

PageSource

Return the IPageSource implementation that this property control uses to read page data.

Declaration
public virtual IPageSource PageSource { get; set; }
Property Value
Type Description
IPageSource

An IPageSource implementation.

Remarks

The returned instance will usually be the base class for the aspx-page.

PropertyName

Gets or sets the name of the property that should be displayed by this control.

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

Please note that the PropertyName attribute is not case sensitive.

Examples

The following example shows how to print the name of the page to HTML:

<episerver:property propertyname="PageName" runat="server" />

PropertyResolver

Gets or sets the PropertyResolver that should be used by the current control instance.

Declaration
protected Injected<PropertyResolver> PropertyResolver { get; set; }
Property Value
Type Description
Injected<PropertyResolver>

PropertyScopeSeparator

Gets or sets the scope name separator.

Declaration
public virtual char PropertyScopeSeparator { get; set; }
Property Value
Type Description
System.Char

The scope name separator.

Remarks

The default value is '.'.

RenderSettings

Gets or sets any render settings for the property.

Declaration
public virtual PropertyRenderSettings RenderSettings { get; }
Property Value
Type Description
PropertyRenderSettings

The render settings for the property.

Remarks

These settings can vary from property to property, consult the documentation for each property for more details on custom properties.

ValidationGroup

Gets or sets the validation group.

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

The validation group.

Methods

CreateChildControls()

Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.

Declaration
protected override void CreateChildControls()

DataBind()

Binds a data source to the invoked server control and all its child controls.

Declaration
public override void DataBind()

EnsurePropertyControlsCreated()

Triggers EnsureChildControls for the Property. Mainly used be control developers.

Declaration
public void EnsurePropertyControlsCreated()

Get<T>(ContentReference)

Gets the specified content link.

Declaration
public T Get<T>(ContentReference contentLink)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The content link.

Returns
Type Description
T
Type Parameters
Name Description
T

GetChildren<T>(ContentReference)

Gets the children.

Declaration
public IEnumerable<T> GetChildren<T>(ContentReference contentLink)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The content link.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>
Type Parameters
Name Description
T

OnPreRender(EventArgs)

Raises the System.Web.UI.Control.PreRender event.

Declaration
protected override void OnPreRender(EventArgs e)
Parameters
Type Name Description
System.EventArgs e

An System.EventArgs object that contains the event data.

Render(HtmlTextWriter)

Renders the control to the specified HTML writer.

Declaration
protected override void Render(HtmlTextWriter writer)
Parameters
Type Name Description
System.Web.UI.HtmlTextWriter writer

The System.Web.UI.HtmlTextWriter object that receives the control content.

RenderErrorMessage(HtmlTextWriter)

Renders an error message to the specified HTML writer.

Declaration
protected virtual void RenderErrorMessage(HtmlTextWriter writer)
Parameters
Type Name Description
System.Web.UI.HtmlTextWriter writer

The System.Web.UI.HtmlTextWriter object that receives the control content.

Remarks

This method is responsible for figuring out and render an error message. It will look at the DisplayMissingMessage to decide if it should render certain errors.

Explicit Interface Implementations

IPageSource.CurrentPage

Declaration
PageData IPageSource.CurrentPage { get; }
Returns
Type Description
PageData

IPageSource.GetChildren(PageReference)

Declaration
PageDataCollection IPageSource.GetChildren(PageReference pageLink)
Parameters
Type Name Description
PageReference pageLink
Returns
Type Description
PageDataCollection

IPageSource.GetPage(PageReference)

Declaration
PageData IPageSource.GetPage(PageReference pageLink)
Parameters
Type Name Description
PageReference pageLink
Returns
Type Description
PageData

IContentControl.CurrentContext

Declaration
PropertyContext IContentControl.CurrentContext { get; }
Returns
Type Description
PropertyContext

Implements

System.Web.UI.INamingContainer

Extension Methods