Create a widget template

Custom widgets are usually represented by a class, which implements their functionality. The mechanism of creating widgets in Sitefinity CMS allows you to specify a template. With a template you can specify the visual representation of your widget. A template is represented by an .ascx file. 

To create a widget template:

  1. In the context menu of your project, click Add » New Folder.
    Name the folder, for example, MyCustomWidgetFolder.
  2. From the context menu of the new folder, click Add » New Item...
  3. From the dialog click Visual C# » Code » Code File.
  4. Name the file the way you want your widget to be displayed in the toolbox, for example MyCustomWidget.ascx.
  5. Click Add.
    An empty .ascx file is generated under the MyCustomWidgetFolder folder.
  6. From the context menu of file MyCustomWidget.ascx, select Properties.
  7. In the Properties pane, set the Build Action property of the file to Embedded Resource.
    You do this to make the template a part of the compiled assembly.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?