This topics describes controls available for rendering of built-in properties for Web Forms-based Episerver sites. The rendering is based on the PropertyControl interface, and the PropertyDataControl base class.
The abstract base class PropertyDataControl does a lot of the underlying work, so you do not need to inherit from any classes in this namespace when you create custom controls. However, custom controls must inherit from System.Web.UI.Control and implement the EPiServer.Core.IPropertyControl interface. PropertyDataControl has the following more important methods and properties:
Note: You can use several of the methods in PropertyDataControl only when you create a Web Forms-based editor. However, in the default edit view in EPiServer 7 or later, you can use Web Forms-based editing if you configured legacy editing, or if you edit dynamic properties or dynamic content.
Change rendering with PropertyControlBase<T>
If you want to change rendering of an existing property, perhaps based on a tag, PropertyControlBase<T> lets you to use any user control. You also can apply the same method to a WebControl by implementing the IPropertyDataControl<T> interface. A generic implementation of IPropertyControl wraps your control. The following example shows a definition that renders an alternative to PageReference when you use the Testing tag.
If you want to change rendering of a property based on the web browser of the current request, map a control adapter using a .browser-file. Because a control adapter inherits from an adapter base class, the EPiServer.Web.PropertyControls.Adapters.PropertyDataControlAdapter base class facilitates implementation of a custom control adapter for a property. PropertyDataControlAdapter implements many of the properties and methods that exist on PropertyDataControl and redirects the method back to the current PropertyDataControl by default, so you can implement the specific methods for which you want to change the behavior. The following example shows a control adapter that overrides the default behavior for EPiServer.Web.PropertyControls.PropertyLongStringControl :
publicclass PropertyLongStringControlAdapter : PropertyDataControlAdapter
Label l = new Label();
l.Text = PropertyData.ToString();
Note: You must use Control.Controls.Add() to add a child control in a control adapter. Also, EPiServer CMS applies control adapters even for inherited classes, so you can apply a PropertyDataControl control adapter to modify the behavior of any control that inherits from ProprtyDataControl.
Mapping presentation of properties with PropertyControlClassFactory
Mapping a PropertyClass through PropertyControlClassFactory overrides which control is used. The following code shows how to map a property to use the second argument, (which is required to inherit from Control and implement IPropertyControl), instead of the default control: