i

ASP.Net A Complete Guide

Themes

Themes:

Themes are the way to define the layout for various controls and can be re-used in multiple pages.ASP.net 2.0 has provided the "Themes." The CSS is also used to format, but it is restricted to the fonts, borders, background, etc. But sometimes there is a need to do the specific formatting.

Below are some essential points of Themes:

  • It can be applied using the configuration files.

  • It has the ability to retain the CSS feature.

  • It is control based not Html Based.

Steps to create the Themes:

  • In the main application, directory creates a folder with a particular name under the App_Theme folder.

  • Then add one or more files with .skin extension under the created theme folder.

  • An application may have more than one theme file. Those should be defined under the Theme folder only.

Note: On application, only one theme file should be active at a time.

Below are the different ways to apply the Themes

Page level theme setting: Theme can be added using the @Page directive

Example:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Index.aspx.cs" Inherits="Default" Theme="MainTheme"%>

 

 

Site-level theme setting: This setting can be used when we need to apply the theme to the whole site. This can be achieved using the configuration file that is the "Web.config" file.

Example:

Apply theme at run time:

We can apply this to the Base page class of the site as each page in the site inherits from this class.

Example:

Page.Theme = Theme1;