Build a form widget: Implementing the client control
In Sitefinity CMS - widgets provide most of their functionality in client code. As the Sitefinity CMS backend, where these controls are used, is fully AJAX-ified and works through services, custom field controls must provide a client API that is called by Sitefinity CMS.
The following procedure shows how to implement the client component for a custom field control:
- Implement a basic client control.
To do this perform the following:
- In the file, type control and press TAB twice.
- Provide the name of the control.
By convention, this must be the same as the fully qualified type name of your server class.
- Inherit from the
FieldControl client class.
registerClass, which, by default, uses
Sys.UI.Control. Change this to
- Include the required properties.
Sitefinity CMS expects every field control or widget to have
set_value() client properties. They must return and save the value of the widget, respectively. The implementation depends on the UI of your custom field. For simplicity, the following code sample only returns and sets the value of a different DOM element, depending on the current mode -
This example is getting and setting the value of the text box control.
FormWidget.js in Sitefinity documentation-samples on GitHub.