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.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?