You must always inherit from the FieldControl class. There are some abstract methods and properties you have to override.
MyCustomFieldControl : FieldControl
// your implementation goes here
As with all Sitefinity CMS widgets that inherit from SimpleView, you must override the InitializeControls method. You can think of this as an alternative of the CreateChildControls method in custom ASP.NET controls. You can implement your control’s logic here.
// your server logic goes here
This property should return a control from the template of your field control, which will display the title. All field controls have a title, displayed in the backend form when in Write mode. You can use the Container.GetControl() generic method that is available in all Sitefinity CMS widgets inheriting from SimpleView, and just supply the ID. You can have a different title control in Read and Write mode.
.DisplayMode == FieldDisplayMode.Read)
DescriptionControl should return a control from the template, which will display the description of your custom field control. As with the TitleControl, you can have a different description in Read and Write mode.
ExampleControl should return a control from the template, which will display an example of the value that your field control expects from the user.
This is not specific to field controls, but all widgets that inherit from SimpleView. You can return null in your project.
Although it is not abstract, we recommend that you override the LayoutTemplatePath property. Here, similar to all widgets in Sitefinity CMS, you should return a path to the template used by your field control. You can either use a path to an embedded resource (recommended), or an external file. For more information, you can read about the VirtualPathProvider.
.LayoutTemplatePath = value;
Back To Top