Making Your Sitefinity Widget Templates Editable through the UI - Part 2

Making Your Sitefinity Widget Templates Editable through the UI - Part 2

November 14, 2013 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

This blog post is an extension to the blog post from Slavo Ingilizov for making widget templates editable trough the UI.

This blog post will address how to make the custom widget template persist in the UI after it has been edited (not removed after a single edit to the template) and how to create a custom resource class which will create new area name for the widget so that it can be placed in different areas from the preexisting areas of the built-in widgets.

1. Registering the widget template and making it persist in the UI.

To make the widget template persist in the class for the widget, add a new attribute ControlTemplateInfo:

[ControlTemplateInfo("CustomControlResources", "FriendlyName", "WidgetArea")]
    public class NewWidget : SimpleView
//rest of the widget implementation is below

ControlTemplateInfo makes the widget template for this widget registered to a specific Area, and it accepts three parameters:

"CustomControlResources" - This is the resource name, I will describe how to create custom resource below.

"FriendlyName" - this is the name of the section toward which this template belongs, in case a single widget has multiple templates registered for it.

"WidgetArea" - this is the Area in which the widget is registered (see screenshot below).

2. Add a custom resource class creating the resource entries used in the above registration.

2.1 Create a class that inherits Sitefinity.Localization.Resource. The class used for the above resources is provided below:

using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Localization.Data;
namespace SitefinityWebApp
    [ObjectInfo("CustomControlResources", ResourceClassId = "CustomControlResources")]
    public class CustomControlResources : Resource
        public CustomControlResources()
        public CustomControlResources(ResourceDataProvider dataProvider)
            : base(dataProvider)
                       Value = "WidgetArea",
                       Description = "The title of this class.",
                       LastModified = "2009/05/13")]
        public string BlogResourcesTitle
                return this["WidgetArea"];
            Value = "Friendtly name of the control",
            Description = "description",
            LastModified = "2010/11/11")]
        public string BlogsMasterViewFriendlyName
                return this["FriendlyName"];

2.2. To register and use the custom resource class in Global.asax, register the class by subscribing to Bootsrapper.Initialized in Application_Start event:

protected void Application_Start(object sender, EventArgs e)
           Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(this.AfterInit);
       private void AfterInit(object sender, ExecutedEventArgs args)
The registered custom resource class can further be extended with additional resource entries from the Administration-> Interface Labels and Messages module.

3. Registering the widget template for the control using the resource class entries

The widget template registration can be altered to include the resource classes for which the widget has been registered.

var initializer = SiteInitializer.GetInitializer();

Stanislav Velikov

Stanislav Velikov is a Tech Support Engineer at Telerik. He joined the Sitefinity Support team in April 2011.

Comments are disabled in preview mode.
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

More From Progress
ProgressNEXT: Premier Event for Modern Application Development
Read More
Seven Reasons to Check Out Sitefinity 11.1
Read More
Getting Started with Your Omnichannel Content Strategy
Read More