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.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?