Link widget components
This article gives an overview of how widget components interact and how you connect them to create a complete widget.
EXAMPLE: Consider you have the following widget components:
- Widget:
HelloWorld.cs
- Widget template:
HelloWorld.asax
- Designer:
HelloWorldDesigner.cs
- Designer template:
HelloWorldDesigner.asax
- Designer controller:
HelloWorldDesigner.js
SAMPLE: You can download all the widget files from folder \WebFormWidgetsSamples\HelloWorld
in Sitefinity documentation-samples on GitHub.
Link the widget
SAMPLE: For a sample code of a widget class, see HelloWorld.cs
in Sitefinity documentation-samples on GitHub.:
Link the designer
SAMPLE: For a sample code of a widget designer, see HelloWorldDesigner.cs
in Sitefinity documentation-samples on GitHub:
- Link to the designer template
In the HelloWorld
sample, the designer class is HelloWorldDesigner.cs
and the designer's template is HelloWorldDesigner.ascx
. The designer class needs to know which template file to load. You do this by overriding the LayoutTemplatePath property.
Because the template of the custom widget is always an Embedded Resource, you must enter a full path to the designer's template.
- Register the control designer script
In the HelloWorld
sample, the control designer class is HelloWorldDesigner.js
. You must register it in the designer by overriding the GetScriptReferences()
method and passing the path to the JavaScript file. Provide a full path name to the JavaScript file including the assembly name.
Register the widget
When you are finished with the development of you widget, you must register it.
For more information, see Register a new widget in Sitefinity CMS toolbox.