Implement the client component for the simple widget designer
You must store the client component in a .js file in the project, where the designer resides.
To implement the client component, perform the following:
- Add a new .js to the project of your designer.
You can name the file the same way as the class.
For example, if the class is named
SimpleWidgetDesigner.cs, name the file SimpleWidgetDesigner.js.
- In the context menu of the .js file, click Properties.
- In Properties pane, set the BuildAction field to EmbeddedResource.
- Open the .js file.
- Create the namespace for the client code.
This is done by calling the registerNamespace of the Type class.
NOTE: You must use the same namespace throughout the entire client code of this file.
- Define the client class.
- Define the prototype for the class by including the following methods:
This method is called when an instance of the class is created. In it, you must call the initialize method of the ControlDesignerBase class.
This method is called when the instance of the class is no longer used. In it, you must call the dispose method of the ControlDesignerBase class.
This method is called when the designer is opened. In it you must get an instance of the widget and populate the UI with the values of the properties of the widget.
This method is called when the changes must be applied to the widget. In it you must get an instance of the widget and set its properties to the new values in the UI.
- Register the client class and specify its base class.
This is done by calling the registerClass method. You must pass the Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerBase as the base class.
Use the following code sample: