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.
The following tutorial demonstrates how to make the template of a custom widget to be editable through the UI.
SimpleView
Perform the following:
InitializeControls
LayoutTemplateName
.ascx
resourceClassId
controlDisplayName
areaName
TemplateKey
NOTE: You must use an instance of the PageManager class to operate with widget templates. In the code sample below, a specific widget template is retrieved with specific Name, AreaName, DataType, and ControlType.
PageManager
Name
AreaName
DataType
ControlType
Use the following code sample:
EditableWidgets
To register and use the custom resource class in Global.asax, register the class by subscribing to SystemManager.ApplicationStart method in the ApplicationStart event. The registered custom resource class can be further extended with additional resource entries from Administration » Interface Labels and Messages.
Register the widget template for the control using the resource class entries. All editable templates are stored in the Sitefinity CMS database. If you edit the templates through the UI, those edits are kept in the database and the template is served from there when the widget is instantiated. If there are no edits, Sitefinity CMS returns the embedded resource. Keeping the templates in the database also gives the possibility to reset them to the default ones. You can always go back one version in the embedded resource, if someone has made the template unusable from the UI.
To create such a database record for your template, you can use the Sitefinity CMS API. You can do this only once in the lifetime of your project in the SystemManager.ApplicationStart method:
The code above creates a new entry in the database with the information you give for your template. That information includes the namespace of your ascx embedded resource, type of the widget, name for the template to display in the UI, the assembly it resides in, etc. From now on your template will be retrieved from the database and will appear in the backend list.
You can also manage templates through the custom control designer. For more information, see Manage custom control templates through the designer.
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