vimodi's WebLog

What is a StyleSheetTheme?

Basically StyleSheetTheme is a Theme which gets applied in very early page cycle before the page control properties applied.

So order is like
    StyleSheetTheme -> Page -> Theme

That means control property set in StyleSheetTheme can be overridden by the control property in Page and control property set in Page can be overridden by the control property in Theme.

For example if StyleSheetTheme contain following default Label skin.
<asp:Label runat="server" Text="StyleSheetLabel" Font-Size="Small" BackColor="Red" ></asp:Label>

and Page Which has StyleSheetTheme and Theme defiened contain a Label contol as
<asp:Label runat="server" Text="PageLabel" Font-Size="X-Large" ></asp:Label>

and Theme contain following default label skin.
<asp:Label runat="server" Text="ThemedLabel" ></asp:Label>

Then the resultant Label shown will look like.
<asp:Label runat="server" Text="ThemedLabel" Font-Size="X-Large" BackColor="Red" ></asp:Label>

Above example is just to show the precedence heirarchy but generally either StyleSheetTheme or Theme will be applied to the page and not both.
StyleSheetTheme has same characteristics Theme except few differences.

  • StyleSheetTheme works in Designer
  • To apply StyleSheetTheme at Site Level define following in web.config

    <system.web>
          <pages styleSheetTheme="Theme1" />
    <system.web>

  • To apply StyleSheetTheme at Page Level

    <%@ Page Language="C#" StylesheetTheme="Theme1"%>

  • To apply StyleSheetTheme dynamically user need to override the StyleSheetTheme property.

    public override string StyleSheetTheme
    {
       get{ retrun "MyStyleSheetTheme"; }
    }

  • To apply a StyleSheetTheme to a control added dynemically user need to call ApplyStyleSheetTheme(Page) method on the control.

    Label lab1 = new Label();
    lab1.ApplyStyleSheetSkin(
    this);

  • EnableThemeing doesnt work with StyleSheetTheme. Setting EnableTheming="false" doesnt stop applying StyelSheetTheme to the page or control.
  • Can not apply SkinId dynemically.

Posted: May 05 2005, 12:35 AM by vimodi | with 8 comment(s)
Filed under:

Comments

TrackBack said:

# May 6, 2005 4:57 PM

panduranga said:

Nice Article.

I have a question. Is there a way that I can apply two css files within a stylesheet and change the css based on some criteria (like based on user credentials).

Thanks,

# June 20, 2008 9:31 AM

Anton Swanevelder said:

Hi panduranga,

You can change the theme based on some criteria by doing this:

Create more than one theme.

Then in your page_load method of your aspx page set the Page.Theme = "Theme name";

Regards,

Anton

# July 9, 2008 5:39 AM

vivek said:

hi Anton

u never add theme in page_load.

u must be set it in page_preinit

# August 20, 2008 8:34 AM

kareem_se said:

can i apply two style sheet to a button skin file differentiated on the basis of SkinID.i.e

<asp:button runat="server" SkinID="orange: CSSFilePath="Orange.css">

<asp:button runat="server" SkinID="Green: CSSFilePath="Green.css">

these two line are in the aspButton.skin file

Plz help me in this regard

# June 8, 2010 9:03 AM

Ranu Mandan said:

thx.. for clearing that

# April 10, 2011 4:42 AM

joel said:

que harĐ“­amos sin su frase excelente  

http://eru1.myftp.biz/  

tabria

# August 19, 2011 4:10 PM

MrBool.US said:

Trying to help, I leave a link to a video that deals with the topic StyleSheetTheme.

Difference between a Theme and a StyleSheetTheme

mrbool.com/.../21789

# January 7, 2012 11:12 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)