Home


.Net, SQL and softball. Musings of a software developer with a softball problem

Tuesday, December 2, 2008

Theming with SkinID

A month or so ago I made a post about theming in .Net, and towards the end of it I said that sometimes on a page you may need to override the theme and create your own style and the example I gave was of a button having a specific style different from the rest.

What I left out of that post (and I actually spent the morning updating my code to reflect this) were SkinIDs. Inside of a skin file you can have multiple definitions for a single control. One of these will be set as default and the rest will be given a SkinID to denote it at the page level. So in my example with the button
<asp:Button ID="btnClear" Text="Clear"  EnableTheming="False" CssClass="Button Clearbtn btn100"
CausesValidation="False" runat="Server" />
Would change to
<asp:Button ID="btnClear" Text="Clear" SkinID="ClearButton" CausesValidation="False" runat="Server" />

And I would have in my Skin file the following line.
<asp:button cssClass="Button Clearbtn btn100" SkinID="ClearButton" runat="Server"/>

One of the nicest things about this is all of your skinIDs will show up on your aspx pages, so Intellesence picks up your IDs so you don't have to remember all of them. It also cleans up the code a bit and you don't have so much repetition.

Labels:

posted by Tom Becker at

0 Comments:

Post a Comment

<< Home