Working with controls
This topic provides you with an overview of controls in Sitefinity and guides you through the common steps when creating a control.
The article contains the following sections:
What is a control
The controls are UI Elements (widgets), which you can place in your Sitefinity frontend. The controls are used for displaying content in your pages. Sitefinity comes with a set of built-in controls, which are ready for use. Such controls are the News, Image gallery and Video gallery. They allow you to display the content from the various Sitefinity modules. To implement functionality, which is not provided by the built-in controls, you can build your own custom controls. Sitefinity also provides control designers for some of the built-in controls. The control designer is a property editor, which allows you to configure the control in Sitefinity backend. The designers can be extended to cover custom controls as well.
For more information, see Controls.
Control types
There are no special requirements for a control, which you want to add to Sitefinity toolbox. You can use controls created for other systems by including them to the Sitefinity toolbox. Following is a list, which represents the most commonly used controls:
-
Built-in Sitefinity controls
For example, News, Image gallery, Video gallery.
-
Standard ASP.NET controls
For example, Hyperlink, Label, GridView, ObjectDataSource.
-
Telerik RadControls for ASP.NET AJAX
Telerik RadControls for ASP.NET AJAX are shipped with Sitefinity.
-
ASP.NET User Controls
Custom developed user controls. For more information, see Creating controls.
-
ASP.NET Custom Controls
Custom developed server controls. For more information, see Creating controls.
-
Module Controls
Controls from custom modules that represent the module's frontend functionality. For more information about modules, see Working with modules.
-
Telerik RadControls for Silverlight
You can also use Telerik RadControls for Silverlight by wrapping them in an ASP.NET control. For more information, see Creating controls.
IMPORTANT: The RadControls coming with the CMS can be used only within the context of the Sitefinity application. You will get a trial message, if you use them in another application.
Built-in controls
Sitefinity comes with set of built-in controls. They are grouped in the following categories:
-
Content
Contains controls that display the content of the different built-in modules, such as News, Blog posts, Events.
-
Navigation
Contains controls that implement navigation throughout the pages of the site, such as Navigation, Archive.
-
Data
Contains controls that are suitable for querying data, such as XML data source, OpenAccess data source.
-
Scripts and Styles
Contains controls that allow styles and scripts to be added to the page contents, such as CSS, Java Script, Google Analytics.
-
Login
Contains controls that are related to the login functionality, such as Login, Login Name, Login Status.
-
Search
Contains controls that are related to the search functionality, such as Search, Search results.
-
Classification
Contains controls that are used for classification of the page, such as Categories, Tags.
-
Newsletters
Contains controls related to the Newsletter module, such as Subscribe form.
-
Users
When adding a new control to the toolbox, you can add it to one of these categories or you can create a new category. For more information, see Registering controls.
The pane with the available controls is displayed when you edit a page. To use a control on your page, you must drag and drop it on the place you want it. For more information about using controls, seeDisplaying content using widgets.
Creating controls
To provide a functionality that the Sitefinity built-in controls do not have, you can create your own control. When creating your own control, you must concern the following:
-
User and custom controls
You must create the control as either a user control or a custom control. You can derive your control from the SimpleView or the SimpleScriptView classes, which are part of the Sitefinity SDK. They are designed to improve the development of controls for Sitefinity. For a detailed step-by-step tutorial on creating controls, see How to create a NewsRotator control.
If you want to enhance your control to have a smoother UI, represented for example, by a Silverlight application, you can do this by hosting the application inside the control. You can also communicate with and pass data to the Silverlight via javascript. For a detailed step-by-step tutorial on creating Silverlight-based controls, see How to create a CoverFlow control.
-
Data dependent and data independent controls
To access the data in the application, your custom control must also be able to communicate with the existing modules in the Sitefinity application. This is achieved by using either the Fluent API or the respective manager class. Your control can also be data independent. An analog clock control, which displays the current time, is an example of such control. For more information on the Fluent API, seeFluent API. For more information on working with data from the modules, see Modules.
-
Control designer and property editor
By default, each control in the Sitefinity toolbox has a property editor, which allows the control to be customized. It includes all of the public properties that are exposed by the control. You can also replace the property editor with a control designer. For more information about the control designers, see Working with control designers.
Registering controls
To use a control, which is not part of the Sitefinity toolbox, you must register it. To register a control, perform the following:
-
Reference the control in the Sitefinity application.
NOTE: This step does not apply for user controls, because they are always part of the application project.
-
Add the control to Sitefinity toolbox in one of the following ways:
For more information, see Adding Controls to the Toolbox.