Build a custom field control: Implement the template

By definition, your field control must provide UI for both displaying and editing the value of a field. This is a typical case where you can use conditional templates. Use the following markup for the template:

First, the template registers the Telerik.Sitefinity.Web.UI namespace, to use the conditional template and SitefinityLabel.

It includes a ConditionalTemplateContainer with two templates in it - one for Read and one for Write mode. It specifies the condition on each of them to look at the value of the DisplayMode property. This property is available in the FieldControl class and is set through the definitions of your control, or automatically.

Each conditional template includes the controls that it needs to show. This sample only includes the required labels for TitleControl, DescriptionControl, and ExampleControl. These IDs correspond to the IDs that are used in the class's properties.

With this, you have a blank template, to which you can add the custom controls for your field control.

Was this article helpful?