Sitefinity CMS provides enhanced user experience for working with custom ASP.NET Core widgets. By default, Sitefinity CMS detects the types of the public properties that you define in the code of the widget and automatically generates the widget editor with the respective fields.
The widget editors support the following:
Out-of-the-box, you get enhanced field editors for the following property types:
Boolean
Enum
Int
double
DateTime
The following screenshot demonstrates the automatically generated editor for the Margin property that consists of TOP, RIGHT, BOTTOM, and LEFT margin properties:
Dictionary
The following screenshot demonstrates the autogenerated property editor of a dictionary of complex objects:
The attribute that determines how many rows to create for the entries in the dictionary is the following: [LengthDependsOn(nameof(ColumnsCount), "Column", "Column ")]
[LengthDependsOn(nameof(ColumnsCount), "Column", "Column ")]
In this example, the number of rows that the column paddings dictionary has is determined by the number of columns that a Section widget has (ColumnsCount). Each Section widget column is a complex object, containing four other properties of type Enum – these are the top, right, bottom, and left paddings that can be one the predefined values – none, small, medium, or large.
ColumnsCount
List
LengthDependsOn
You can customize the automatically generated fields by using the following predefined attributes:
DefaultValue
ConfigurationDefaultValue
appconfig.json
Description
Placeholder
The code above generates the following fields in the widget editor:
Sitefinity CMS supports the following attributes:
EmailAddressAttribute
MaxLengthAttribute
MinLengthAttribute
RangeAttribute
RegularExpressionAttribute
RequiredAttribute
StringLengthAttribute
UrlAttribute
These validation attributes are provided in Microsoft's .NET System.ComponentModel.DataAnnotations Namespace.
You can specify where the properties are displayed. Sitefinity CMS support the following levels of differentiation:
The following code sample, moves the first property to the advanced section and puts the second property in a particular section:
You can hide or display fields depending on the value of a related property.
You do this by using the ConditionalVisibilityAttribute in the following way:
ConditionalVisibilityAttribute
This sample adds a rule that displays field MyProperty, only if the Title property is equals to My custom title.
MyProperty
Title
My custom title
The ConditionalVisibilityAttribute takes a parameter that is defined in the following JSON:
When you press CTRL+ALT+C, all the widget’s properties and their values are copied to the clipboard. Then, you can paste them in a text editor of your choice.
CTRL+ALT+C
You can also paste values in the widget editor by pressing CTRL+ALT+V. Values are validated, in the same way, as if they are entered directly in the field editors.
CTRL+ALT+V
EXAMPLE: If you have two properties - CustomerName and CustomerAge, you can enter their values in the widget editor, by pasting the following: {"CustomerName":"MyName","CustomerAge":"5"}
CustomerName
CustomerAge
NOTE: This feature is available for Chrome browser only.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
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.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important