Click here to Skip to main content
13,707,779 members
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 11 Oct 2013
Licenced CPOL


, 11 Oct 2013
Rate this:
Please Sign up or sign in to vote. 2.0 came with a new feature called a theme. A theme is a collection of property settings that allow you to define the look of pages and

Editorial Note

This articles was originally at but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant. 2.0 came with a new feature called a theme. A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in a Web application, across an entire Web application, or across all Web applications on a server.

Themes are made up of a set of elements: skins, cascading style sheets (CSS), images, and other resources. Skins provide the ability to apply server-side styling to a control on the server side.  By providing a SkinID for the skin, this skin can be applied to a control that matches the skin type and SkinID; otherwise, if the SkinID is left null, then the skin will be applied globally.  For instance, take a look at the example below:

 <asp:Button SkinID="One" runat="server" BackColor="Blue" />

This skin is applied to any button that has a SkinID of "One".  However, the following skin is applied to every button:

<asp:Button runat="server" BackColor="Yellow" />

A button with a SkinID set will use that skin over the skin that's globally applied.  At a minimum, a theme will contain skins, but it's common to include CSS files. Themes are defined in special directories in your Web site or on your Web server.  You can apply Themes dynamically also, but the theme should be applied only in the page_Preinit event by assigning a value to the Page.Theme property.

You can also can theme third-party controls by adding them into a .skin and adding (if required) their reference.

Best practices

When to use themes/skins

  • foreground images cannot be controlled by CSS
  • CSSClasses have to be applied by hand for a control to change it's look and feel.
  • For advanced controls and collections
  • Switch image files based on the current theme

What belongs in a theme

  • CSS file specific to ASP.NET controls
  • Images used for the advanced controls or other foreground images

What does not belong in a theme

  • Shared CSS files/styles
  • Print CSS files/styles
  • Global images
  • Any content that has nothing to do with the content affected by the theme/skin



  • Customize my Site with Profiles and Themes?


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ASP.NET Community
United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Collaborative Group

760 members

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid