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.
<%@ Control Language="C#" %>
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
We are doing several things in this template. First, we are registering the Telerik.Sitefinity.Web.UI namespace, to use the conditional template and SitefinityLabel.
We are including a ConditionalTemplateContainer with two templates in it - one for read and one for Write mode. We have specified 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.
In each conditional template, we can include the controls that we need to show. In the sample, we have only included the required labels for TitleControl, DescriptionControl and ExampleControl. Those IDs correspond to the IDs we have used in our class's properties.
With this, we have a blank template, to which we can add the custom controls for our field control.
Back To Top