Themes allow quick change of the presentation and layout of a page using a combination of style sheets (.css) and skin (.skin)
files, as well as graphics. In this QuickStart, the following items will be created:
- Test project in Sitefinity;
- Simple page template for the site;
- Page using the template;
- Theme using both .css and .skin files for the page template;
Finally, some content will be added to the page to see the theme applied.
Adding a New Project to Sitefinity
To create a new project in Sitefinity:
- Launch Sitefinity Project Manager by selecting Start Menu > All Programs > Telerik > Sitefinity
3.2 > Sitefinity 3.2.
- Click Create New Project.
- Set the new project name to QuickStart, and then click Next.
- Below the title "Select a template" select the first radio button: "Use no template" and click Create this project.
- When the project has been created, click Go to administer the project.
- When asked what database to use, select your database, and then press Continue.
- If your database is SqlExpress ,give the admin user a password and an e-mail address, and then press I’m done (see Figure 1). If it
is other type of database, set the connection and then press I’m done.
-
Sign in as admin.
Figure 1
Creating the Master Page Template
Create a master page called MasterPage1.master and save it to the C:\ folder.
Modify the code of the master page as follows:
| MasterPage1.master |
Copy Code |
<%@ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
< html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
<title>My
Master</title>
</head>
<body>
<form id="form1" runat="server">
<div id="sidebar">
<asp:contentplaceholder id="SidebarContent" runat="server" />
</div>
<div id="main">
<asp:contentplaceholder id="MainContent" runat="server" />
</div>
</form>
</body>
</html>
|
Adding the Page Template to the Web Site
To make the master page available to a Web site:
- Open the Administration panel for the QuickStart Web site in your browser. You will find it at http://localhost/QuickStart/admin/.
- Sign in as admin with the password you gave it earlier.
- Click Pages from the main menu to access the Page Manager.
- Click Templates to access the master pages area.
- Click Upload Master Page to generate the template.
- Set Template Name to MyMaster and Master Page to C:\MasterPage1.master. (See Figure 2)
- Click Upload this master page
Figure 2
Opening the QuickStart Web Site in Visual Studio
- Start Microsoft Visual Studio if it is not already open.
- Select File > Open > Web Site.
- Select File System from the choices on the left.
- Browse to the folder where the QuickStart site has been created (by default, this is C:\Program Files\Telerik\Sitefinity3.2\WebSites\QuickStart). (See
Figure 3)
- Click Open.

Figure 3
Creating the Theme
- Right-click to select the App_Themes folder in the Solution Explorer and then select Add ASP.NET Folder > Theme.
- Name the new folder MyTheme.
- Right-click to select the MyTheme folder, and then select Add New Item.
- Select the Style Sheet template.
- Name the new item MyStyles.css. (See Figure 4)
- Click Add.

Figure 4
-
Right-click to select the MyTheme folder, and then select Add New Item.
-
Select the Skin File template.
-
Name the new item MySkin.skin. (See Figure 5)
-
Click Add.

Figure 5
Adding Code to the Style Sheet
The code in the style sheet defines a basic layout for pages based on the MyMaster template; it also defines how <h1> text is
rendered.
- Open the MyStyles.css page in Visual Studio.
- Replace its code with the following, and then save the file:
| MyStyles.css |
Copy Code |
|
#sidebar
{
float:left;
padding : 10px;
margin-right : 10px;
border : 1px solid red;
} #main
{
float: left;
padding : 10px;
border : 1px solid green;
width : 700px;
} h1
{
font-family : Arial;
font-size : x-large;
color : Red;
}
|
Adding Code to the Skin
The code in the skin defines how <asp:hyperlink> elements will be rendered.
- Open the MySkin.skin page in Visual Studio.
- Replace its code with the following, and then save the file:
| MySkin.skin |
Copy Code |
|
<asp:HyperLink runat="server" BackColor="AliceBlue" Font-Bold="true" Font-Underline="false" />
|
Creating a Page and Applying the Theme
- Open the Administration panel for the QuickStart Web site in your browser. You will find it at http://localhost/QuickStart/admin/.
- Sign in as admin with the password admin.
- Click Pages in the Dashboard to access the Page Manager.
- Click Create a Page.
- Name the page Themes.aspx. Leave the other properties at their default.
- Click Create this page.
- Choose MyMaster from the Page Template drop-down box, and MyTheme from the Theme drop-down box. (See Figure 6)
- You will see the red and green outlines around the content areas of the page as set by the style sheet.
- Click Publish.

Figure 6
Adding Content Styled by the Theme
- With the Themes page selected in Page Manager, click Edit this Page.
- Add a Generic Content control from the Add Controls section on the right, the Generic Content group, and place
it at the MainContent content area.
- Click Edit on the Generic Content control.
- Type This is a Css-styled H1 in the text box.
- Select the text, and style it as Heading 1. (See Figure 7)
Figure 7
- Click I’m done. You will see the text rendered as large, red text as it is set in MyStyles.css.
- Add a Hyper Link control from the Navigation group of the Add Controls section, and place it at the
MainContent content area.
- Click Edit on the hyperlink control.
- Set the Text property to "This is a skinned hyperlink". (See Figure 8)
Figure 8
- Click I’m done.
- Click Preview.
- You will see the hyperlink in bold text with a light blue background and no underline as set in MySkin.skin. (See Figure 9)
- Click Publish.

Figure 9
See Also