This topic provides information about what controls are, how can they be used and when they should be used in Sitefinity.
When referring to User Interface concepts, the controls in Sitefinity, are named Widgets. Whenever we refer to Widgets, me mean controls.
What are controls?
Content and functionality of Sitefinity Pages are defined through Controls. Regardless of what you want your page to do, you will ultimately have to do it with a control. Here are a few examples of how controls define the content and functionality of pages in Sitefinity:
- Displaying some text on your Page - Use Content Block control
- Displaying the blog posts on your page – use Blog Posts control to display the posts
- Displaying News on your page – use News control to display news
- Displaying a Menu on your page – use the Menu control to display the navigation
Pages in Sitefinity are only containers,while the content and functionality are added through controls.
The Control concept is the same as the one for an ASP.NET control.
What Kinds of Controls can be Used with Sitefinity?
Sitefinity supports five types of controls:
- Built-in Sitefinity controls (such as Blog Posts), Field Controls, Sitefinity Specific Controls
- Standard ASP.NET controls (such as HyperLink, GridView, XmlDataSource)
- User Controls (such as standard ASP.NET user controls - .ascx files – which developers can included to the Sitefinity toolbox)
- Custom Controls (such as compiled controls - .dll files – which developers can include to the Sitefinity toolbox)
- Custom module controls (such as user or custom controls, which are registered in Sitefinity by the module to provide front-end functionality for the module)
When developing controls for Sitefinity (be they User Controls or Custom Controls), there are NO special requirements imposed by Sitefinity. It is possible to use controls created for other systems by simply including them to the Sitefinity toolbox.
How Do Controls Achieve Their Intended Functionality?
Controls generally have properties that should be set so that controls could function in the desired manner. Let’s consider the Blog Posts control which displays blog posts. A user that wishes to display blog posts on a page needs a way to tell the control from which blog the posts should be displayed, how many posts should be displayed at one page, how are they going to be displayed, and so on. Controls are configured through a built-in Sitefinity property grid and/or a control designer. When a control developer builds a control, all properties that the end user should or could modify need to be declared as public properties. Sitefinity will automatically generate property grid editor that will allow the end user to modify these properties directly from the browser. In addition to this, the developer does no need to worry how these properties are going to be persisted (remembered), because Sitefinity will automatically save all the values entered by the user into a database. Generally, controls have two modes for editing properties. One is the automatically-generated property list (which is called Advanced mode, because it lists all public properties), and the other one is the control designer (which is called Basic mode, because control creator can create any desired user interface to allow for simple and streamlined setup of the control). Both modes are essentially providing the same funcitonality – configuring properties; still, this is done in a different manner. Let’s take a look at the two modes provided by Blog Posts control to see the difference (Figure 1):
Figure 2 shows the advanced mode: