HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Property attributes

Describes attributes available for properties in Optimizely Content Management System (CMS).

Properties are the fields in content, such as pages and blocks, where editors enter information. You can apply different attributes to properties, to describe their purpose and how they should behave.

Consider the following when working with properties:

  • Use an intuitive naming of properties in code, and set a "friendly" display name and description, to help editors understand the purpose of a property (attributes Name, Description).
  • Organize related properties under the same tab in edit view, and in logical order with the most frequently used ones at the top (attributes GroupName and Order).
  • Consider adding field value validation, default values, or required fields, where applicable.

Available attributes

The following attributes are located in the EPiServer.DataAnnotations namespace.

Attribute nameDescriptionBehavior, if not specified
BackingType(Type)Defines the PropertyData type used to store values for this property. Must be a type inheriting from PropertyData.The backing type is auto-determined. See Default Backing Types.
CultureSpecific(bool)Defines if this property should have a different value for each language.Properties will not be culture-specific.
Searchable(bool)Defines if the property value should be searchable.String properties are searchable, other property types are not.
IgnoreCMS ignores property and will not be backed by a PropertyData type.

(When CMS ignores the property, it is technically possible to assign the property even though the content is read-only. To avoid that, implement a setter that checks the IsReadOnly property before assigning fields. Content is stored as read-only singletons in the cache so it is impossible to use ignored properties for assigning state related to a single request, as that would cause serious concurrency issues.)
Property is not ignored.
AllowedTypesAllows or restricts certain items to be added to the property. This attribute only works with ContentArea, ContentReference, and ContentRefeferenceList type properties. See Restrict content types.By default, items can be added to the property. 

The following attributes are located in the System.ComponentModel.DataAnnotations namespace.

Attribute nameDescriptionBehavior, if not specified
RequiredDefines if a value for this property must be set before being able to save a page of the parent type.Property value is not required.
ScaffoldColumn(bool)Defines if this property is visible in edit view.The property is visible in edit view.
Order=..., Prompt=...)
The Name, Description, GroupName, Order, and Prompt properties are used to set the EditCaption, HelpText, Tab, FieldOrder, and placeholder or watermark text, respectively.EditCaption is set to the name of the property. HelpText is NULL. The prompt is NULL.
UIHintUsed to select editor or renderer or both by defining a hint string. You can use EPiServer.Web.UIHint to add hints for known types in the system, for instance UIHint.Image.The default editor and renderer for the type is used.
StringLengthSets a maximum length for strings. Note that this attribute cannot be used for properties of type XhtmlString.No length restriction.
RegularExpressionValidates the input format. Usually used for string properties.No validation of the input.
RangeDetermines the valid range for numeric properties.No validation of range except the minimum/maximum values for the value type (For instance Int32.MinValue and Int32.MaxValue).
EditableIndicates whether a property is editable.The property is editable.

The following attributes are located in the EPiServer.Cms.Shell.UI.ObjectEditing namespace.

Attribute nameDescriptionBehavior, if not specified
ReloadOnChangeDefines if the whole editing context (i.e. OPE or Forms View) should be reloaded on every value change.

This attribute is useful when dealing with dependent properties where one property depends on the value of one or more other properties from the same model.

Note that this attribute does not work in Quick Edit dialog because there is no Autosave in the Quick Edit dialog box.

This attribute does not work when creating a content instance because there is nothing to refresh yet (the content item has not been created yet).
The context will not be reloaded on value change.

The following image shows how the attributes are mapped to settings in the admin view:


Default backing types

If the BackingType attribute has not been set for a property, the backing type is automatically assigned to a PropertyDefinitionType where the corresponding EPiServer.Core.PropertyData.PropertyValueType matches the property type. That means that if there is a PropertyData implementation (can be a custom property) with matching PropertyValueType that definition is used. Otherwise, the backing type is assigned according to this table.

See Built-in property types for details on using the correct type.

Property typeBackingType


Sample code using many of the attributes described in this article.

using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.Shell.ObjectEditing;
using EPiServer.Web;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace CodeSamples {
    DisplayName = "My Page Type",
    Description = "Description for this page type",
    Order = 1024,
    GUID = "9CBBF910-CB5A-4C72-83AA-EDCF02E8A2BD",
    GroupName = "My Group",
    AvailableInEditMode = true)]
  [AvailableContentTypes(Include = new Type[] {
    typeof (MyPageType2), typeof (MyPageType3)
  [Access(Users = "niis", Roles = "CmsEditors")]
  public class TypedPageWithAttributeSample: PageData {
      Name = "My Heading",
      Description = "Heading for my page type.",
      GroupName = "My Tab",
      Order = 64)]
    public virtual string Heading {

    //An integer between 0 and 130.
    [Range(0, 130)]
    public virtual int Age {

    //Validating against a given regular expression.
    public virtual string CustomValidation {

    //A string with a maximum length of 20 characters.
    public virtual string Header {

    //Any URL
    public virtual Url RedirectPage {

    //Reference to an image in the EPiServer media system.
    public virtual ContentReference Logotype {

    //URL to image is also supported but mostly for upgrade support or when there is a need to add custom query parameters to the URL.
    public virtual Url LogotypeAsUrl {

    //Creates a selection of predefined values.
    [SelectOne(SelectionFactoryType = typeof (CustomLanguageSelectionFactory))]
    public virtual string LanguageSelection {

    //Creates a selection of predefined values with the option to select several items.
    [SelectMany(SelectionFactoryType = typeof (CustomLanguageSelectionFactory))]
    public virtual string MultipleLanguageSelection {

  public class CustomLanguageSelectionFactory: ISelectionFactory {
    public IEnumerable < ISelectItem > GetSelections(ExtendedMetadata metadata) {
      var languages = new List < SelectItem > ();

      languages.Add(new SelectItem() {
        Text = "English", Value = "en"
      languages.Add(new SelectItem() {
        Text = "Swedish", Value = "sv"
      languages.Add(new SelectItem() {
        Text = "Norwegian", Value = "no"

      return languages;

  [AvailableContentTypes(IncludeOn = new Type[] {
    typeof (TypedPageWithAttributeSample)
  public class MyPageType1: PageData {}

  [AvailableContentTypes(Exclude = new Type[] {
    typeof (TypedPageWithAttributeSample)
  public class MyPageType2: PageData {}

  [AvailableContentTypes(ExcludeOn = new Type[] {
    typeof (MyPageType1)
  public class MyPageType3: PageData {}

  [AvailableContentTypes(Availability = Availability.None)]
  public class MyPageType4: PageData {}