Map EPiServer properties to custom property controls

This article was migrated from an older iteration of our website, and it could deviate in design and functionality.


The PropertyControlClassFactory class makes it easy to map EPiServer properties to custom property controls to modify how properties are rendered.

Estimated read time : 2 minutes

Jump to

Use your own property controls in the EPiServer UI

If the standard EPiServer property controls don’t meet your requirements you can easily configure the standard EPiServer properties to use custom property controls through the PropertyControlClassFactory class.

You can use a PlugInAttribute or InitializableModule class to do it. Here’s an example mapping the different string properties to our own string property controls:

using EPiServer.Core;
using EPiServer.SpecializedProperties;
 
namespace My.Website
{
    /// <summary>
    /// Maps EPiServer property types to our own property control types
    /// </summary>
    public class PropertyControlsSetup : EPiServer.PlugIn.PlugInAttribute
    {
        public static void Start()
        {
            PropertyControlClassFactory.Instance.RegisterClass(typeof(PropertyString), typeof(My.Website.PropertyStringControl));
            PropertyControlClassFactory.Instance.RegisterClass(typeof(PropertyLongString), typeof(My.Website.PropertyLongStringControl));
            PropertyControlClassFactory.Instance.RegisterClass(typeof(PropertyXhtmlString), typeof(My.Website.PropertyXhtmlStringControl));
        }
    } 
}

Now, whenever a string property is rendered it will be rendered using our custom property controls. Another approach would be to use control adapters, but that’ll have to be a topic for another post.

If you're new to EPiServer you may want to check out this introduction to EPiServer properties.