DCSIMG
A few insights about Themes and skins - Pini Dayan

Pini Dayan

The best thing about a boolean is even if you are wrong, you are only off by a bit.

A few insights about Themes and skins

Hi, I  decided to summarize some insights about ASP.NET Themes and Skins . These are a little bits and bytes on this area. so here they are:

1. In addition to adding a "Theme" property to the Page directive such as:

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

There is also another property we can use: "StyleSheetTheme" such as:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
           
Inherits="Themes_and_Skins_Default" StylesheetTheme="BlueTheme" %>

So what is the difference? Very simple!  The difference is when we override the Theme settings in the server control itself. Say I have a TextBox control on the page with a property of BackColor set to "chocolate" color. this Button has a control skin that specifies other color (lets say white).
Here is the control on the ASPX file:
<asp:TextBox ID="TextBox1" BackColor="chocolate"
               
ForeColor="white" runat="server"></asp:TextBox>

And Here is the control skin in the skin file:

 <asp:TextBox runat=server BackColor="White" />

What happens then? does the properties from the skin file win or the properties on the control wins? Well this is exactly the case we want the know the difference between  "Theme" and "StyleSheetTheme". If the page contains "Theme" definition then the Theme wins ( the skin file) and if we use "StyleSheetTheme" the control itself wins. (just like css cascading - hence the name "StyleSheetTheme").

2. Say we have an application level Theme (One that is in the web.config and influence all the pages). We can disable this Theme from being applied to some pages by using the Page directive "EnableTheming" and set it to false. like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
    Inherits="Themes_and_Skins_Default2" EnableTheming="false" %>

This can be done in the control level also. We can even say to this page to use a different Theme.

3. Themes and master pages:When we use Master pages in our application the Master directive also has a EnableTheming property.As it turns out the master page takes precedence over the content page. This means that even if you specified in the web.config some Theme you with that all pages will get and the master page specifies EnableTheming="false" any content page that will try to turn it on" will fail.

This is however not the case for a control level.

 

Hope this helps :)

Pini Dayan

 

 

Comments

Shlomo said:

מידע מעניין

תודה על השיתוף

# January 29, 2009 8:50 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: