views:

125

answers:

2

Since Themes in ASP.NET are used to style elements of your site, I was just wondering why would you use Themes rather than CSS, or is it common practice to use both? If so, when would you opt for one versus the other and why?

Just seems to me like Themes are kind of unnecessary, so I am just looking on clarification if there really is a good reason to use them, or it's just a part of the framework as an alternative(unnecessary) step to styling your site.

+1  A: 

Themes have the benefit of being tightly integrated into the whole .NET environment so that things get themed without needing to specify their styles. It happen automagically like lots of other things in .NET. Based on that I can see the appeal for some people.

That being said, I personally never use the whole themes deal because I feel like it requires you to maintain two different sets of styles. One that's part of the theme and then others that are inevidently needed outside of the whole theming deal.

Maybe I'm just a control freak or dislike themes due to bad usage on previous projects.

Brian Hasden
@brian - thanks for your response. those are my feelings as well, that's why i asked. Thought maybe I was misunderstanding something. +1
jaywon
+3  A: 

Imagine you have a site that, for whatever reason, uses dozens of asp:Calendar controls.

To style them with CSS alone, you'll have to set loads of properties on each one: DayStyle and TitleStyle and NextPrevStyle and on and on...

Using a theme will allow you to set all of those properties just once, and have it apply to every asp:Calendar on the site. The theme would contain the same CSS, but also the declaration of how to apply that CSS to server controls, which is something you can't easily do otherwise.

Of course, as Brian Hasden already said, you'll probably need some "global" CSS that lives outside of the theme (particularly if your site has multiple themes).

Matt Bishop
+1 for describing how themes are used better than I did, however in the situation you described I usually just set the CssClass property and then define everything related to the Calendar in the CSS using selectors and such.
Brian Hasden
interesting. yes I can see how that could be useful. thanks for the response. +1
jaywon