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.
Feather MVC-based widgets differ from the standard Sitefinity CMS widgets by their design and functionality. These widgets come with new property editors based on the Bootstrap framework and AngularJS. For the UI of these widget Feather provides predefined packages based on different frontend frameworks that provide built-in styling options for your website. For more information, see feather-packages and feather-widgets repositories on Sitefinity CMS GitHub.
The following tutorial demonstrates how to create a new Feather MVC widget.
Mvc
Views
System.Web
System.Web.Mvc
Telerik.Sitefinity
Telerik.Sitefinity.Mvc
Telerik.Sitefinity.Frontend
AssemblyInfo.cs
using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes;
[assembly: ControllerContainer]
Models
MessageWidgetModel.cs
namespace
MyFirstMvcWidget.Mvc.Models
{
public
class
MessageWidgetModel
/// <summary>
/// Gets or sets the message.
/// </summary>
string
Message {
get
;
set
; }
}
Controllers
MessageWidgetController.cs
MyFirstMvcWidget.Mvc.Controllers
[ControllerToolboxItem(Name =
"MessageWidget"
, Title =
, SectionName =
"MvcWidgets"
)]
MessageWidgetController : Controller
[Category(
"String Properties"
/// This is the default Action.
ActionResult Index()
var model =
new
MessageWidgetModel();
if
(
.IsNullOrEmpty(
this
.Message))
model.Message =
"Hello, World!"
else
.Message;
return
View(
"Default"
, model);
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.
System.Web.Mvc.Controller
Index
ActionResult
Message
Model
Mvc/Views/MessageWidget
@model MyFirstMvcWidget.Mvc.Models.MessageWidgetModel
<
h1
>
@Html.Raw(Model.Message)
</
NOTE: TheRaw helper method is introduced in MVC 3 and it helps to output any HTML without encoding it.
Raw
MyFirstMvcWidget
You can use the widget from the MvcWidgets section on any page.
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