The following article describes the process of creating a simple .NET Core widget. This sample demonstrates how to create a ViewComponent that will be used to display a configurable message.
ViewComponent
GITHUB EXAMPLE: You can find the whole sample in Sitefinity GitHub repository » Hello world widget.
You can also use the following video as a guideline to creating custom .NET Core widgets:
Renderer
View component explained:
[SitefinityWidget]
InsertWidget
InvokeAsync
IViewComponentContext<T>
After you implement new widgets, you register them with the renderer so they can appear in the widget toolbox dialog. To do this, you decorate the widget view component class with the [SitefinityWidget] attribute. Using this attribute, you define the following optional properties of the widget:
Title
Category
Progress.Sitefinity.AspNetCore.ViewComponents.WidgetCategory
Section
Progress.Sitefinity.AspNetCore.ViewComponents.WidgetSection.
Warning
EmptyIcon
EmptyIconText
EmptyIconAction
Progress.Sitefinity.AspNetCore.ViewComponents.EmptyLinkAction
SeparateWidgetPerTemplate
Order
Like in the ASP.NET MVC widgets, the ASP.NET Core widgets persist your public properties and provide user-friendly interface to edit them though the designer when editing your pages.
ASP.NET core widgets support Autogenerated widget property editors. Therefore, based on the attributes, Sitefinity autogenerates user-friendly editing interface for the widgets.
NOTE: Only the public properties from the model are persisted and not the public properties that you may have in the ViewComponent.cs file. This way, the business logic is better separated from the rendering.
ViewComponent.cs
Views/Shared/Components/HelloWorld
HelloWorld
RESULT: After you build the project, the widget will be displayed inside the widget selector when editing a page.
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