IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
Sitefinity CMS MVC-based widgets come with property editors based on the Bootstrap framework and AngularJS. For the UI of these widgets, Sitefinity CMS provides predefined packages based on different frontend frameworks that provide built-in styling options for your website.
The following procedure demonstrates how to create a new Message widget.
IMPORTANT: When creating your widget files, make sure you abide by the naming conventions. For more information, see Naming conventions.
NOTE: You can also create the Class Library outside of the SitefinityWebApp project in an external project. For more information, see Create widgets in external assemblies.
AssemblyInfo.cs
using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes;
[assembly: ControllerContainer]
Models
MessageWidgetModel.cs
Controllers
IMPORTANT: The class must have the suffix Controller in its name.
MessageWidgetController.cs
In the code above, you build the model and pass it to the view. That is, you define the actions that correspond the UI, relative to the page, on which you place the widget. Your controller must inherit the System.Web.Mvc.Controller class. You add an Index method that returns an object of type ActionResult. The Index action returns a list of items from the model. You modify the code of the Index action to populate the Message of the Model. In addition, you decorate the controller with the ControllerToolboxItem attribute, which automatically registers your widget in the Sitefinity toolbox. For more information, see Register new widgets in Sitefinity CMS toolbox.
System.Web.Mvc.Controller
Index
ActionResult
Message
Model
Mvc/Views/MessageWidget
NOTE: If you are creating the widget in an external project, in the Properties section of the files, set its Build Action to Embedded Resource. Make sure the Sitefinity version referenced in the external assembly is the same as the one your project is using.
NOTE: The Raw helper method is introduced in MVC 3 and it helps to output any HTML without encoding it. You use the Raw method only when you trust the source of the embedded resource. In case you want to ensure your HTML content is safe, leverage Sitefinity CMS HTML sanitization.
Raw
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important