Apply ASP.NET Themes
Themes are made up of a set of elements: skins, cascading style sheets (CSS), images, and other resources. At a minimum, a theme will contain skins. Themes are defined in special directories in your Web site or on your Web server.
Skins
A skin file has the file name extension .skin and contains property settings for individual controls such as Button, Label,TextBox, or Calendar controls. Control skin settings are like the control markup itself, but contain only the properties you want to set as part of the theme. For example, the following is a control skin for a Button control:<asp:button runat="server" BackColor="lightblue" ForeColor="black" />
You can apply themes to a page, a Web site, or globally. Setting a theme at the Web site level applies styles and skins to all the pages and controls in the site unless you override a theme for an individual page. Setting a theme at the page level applies styles and skins to that page and all its controls.
By default, themes override local control settings. Alternatively, you can set a theme as a style sheet theme, so that the theme applies only to control settings that are not explicitly set on the control.
To apply a theme to a Web site
1. In the application's Web.config file, set the <pages> element to the name of the theme, either a global theme or a page theme, as shown in the following example:
<configuration>
<system.web>
<pages theme="ThemeName" />
</system.web>
</configuration>
To apply a theme to an individual page
Set the Theme or StyleSheetTheme attribute of the @ Page directive to the name of the theme to use, as shown in the following example:
<%@ Page Theme="ThemeName" %>
<%@ Page StyleSheetTheme="ThemeName" %>
kins defined in your theme apply to all control instances in the application or pages to which the theme is applied. In some cases, you might want to apply a specific set of properties to an individual control. You can do that by creating a named skin (an entry in a .skin file that has a SkinID property set) and then applying it by ID to individual controls.Applying Skins to Controls
Skins defined in your theme apply to all control instances in the application or pages to which the theme is applied. In some cases, you might want to apply a specific set of properties to an individual control. You can do that by creating a named skin (an entry in a .skin file that has a SkinID property set) and then applying it by ID to individual controls.
To apply a named skin to a control
· Set the control's SkinID property, as shown in the following example:
<asp:Calendar runat="server" ID="DatePicker" SkinID="SmallCalendar" />
If the page theme does not include a control skin that matches the SkinID property, the control uses the default skin for that control type.
0 comments:
Post a Comment