Geeks With Blogs

Andy Johns' Blog Andy's twisted brain....

Yes, yes, I know pro-ASP.NET Theme people will say "you can use CSS with themes, it's not an either-or!" but my thoughts on this matter are the interaction between Themes and CSS is weak and not well integrated.

In a large sense Themes and CSS are attempting to accomplish the same thing: abstract the presentation, and assign uniformity throughout a web site. The problem I have with Themes is they don't really seem to offer many advantages over CSS, they introduce problems when using CSS, and CSS is really the standard when it comes to this sort of thing in a modern web site.

Issue #1 : All CSS files in a Theme are automatically linked into all pages that use that Theme. But wait! I have CSS files for specific controls that I only want linked to pages that use that control. Ick, I want finer grained control.

Issue #2: Backwards inheritance. We're coding in ASP.NET, we're familiar with the concept of classes, and subclasses, and how downstream classes can override behaviors from upstream classes. OOP 101, and something that flows very nicely with the CSS concept of Cascading. It's very useful too, say when you have a high-level CSS style that needs a minor tweak on a single page. In Themes it's the theme that rules, if a given page needs a minor tweak, tough.

Issue #3: Multiplicity. One Theme per page, no exceptions. Pretty inflexible in my mind. With CSS I can assign any number of classes to a markup element, and several CSS files per page. That's been quite useful in the past for me.

Ok, ok, let's look at some of the "positives" of Themes: (I'm afraid I'm going to go into sarcasm mode here....)

You can use skin files to add markup to common elements. A common example often suggested is to setup templates for GridViews. Yeah, because all my grids on my pages are exactly the same.... Oh wait, that's actually really rare...

You can use Default Themes or Themes created by Microsoft or other third parties. Woo-hoo, just what I want, my web site to look exactly like some other web site. Thank you, no.

Organization: your images, CSS, JavaScript, skins, etc is all neatly contained in a single directory structure. Ok, yeah, but I can do that with my own structure and CSS too. In fact Themes can introduce some odd resource reference problems with combined with CSS.

Ok, ok, so do I think Themes suck? No. They have a purpose, and some web developers might find them really nice and useful. However, I don't think that CSS and Themes play all that nicely, and if you're looking at doing a really CSS-based UI for your web site, you probably don't need the extra baggage that Themes bring along.

Am I missing something? Have a good example of CSS and Themes interacting? Can you offer up a solution to Issue #1 above? I'd love to hear it, leave a comment....

It's entirely possible I'm completely missing the boat here, but I don't think so....

-Andy

Posted on Thursday, January 18, 2007 3:54 PM | Back to top


Comments on this post: ASP.NET Themes or CSS - Pick one

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
Good post. I am new to the ASP.NET world and am starting to come to the same conclusions. Themes aren't flexible and are way too restrictive. I wish they did play nicely because I definitely think that there could be some benefit to being able to switch themes.
Left by Brian Hartsock on Sep 25, 2007 7:27 PM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
<p>Nice blog... I'm reasonably confident with CSS, and am just starting ASP.NET development, and I saw one blog which said that Themes are more powerful. I wasn't sure, and after reading this blog I think I'll stick with CSS :)</p>
This site has an extended discussion of the same topic, and most posters reach the same conclusion.
Left by Stephen on Mar 30, 2009 11:04 PM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
very good article ilike it
Left by Medical Shopping on Jul 23, 2010 12:35 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
free download movies from freemovietag.blogspot.com
Left by free download full movie on Jul 23, 2010 12:38 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
u learn about search engine optimization and website promotion from my blog semtutorials.blogspot.com
Left by search engine marketing on Jul 23, 2010 12:38 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
I don't know what have you tried with themes but I am using now themes with css. 4 example, in my project I have 2 types of gridviews and one type of button. As a developer you what to be as fast as possible, so I have a theme for all the buttons and in this theme I have 2 skins for my gridviews (the theme uses css class). When I'm using these theme on one page all my buttons show as declared in the theme and for my gridviews I'm choosing the skin I want to use. If I don't use themes then on every page in my project I have to change the design of every gridview and button. And what about being able to switch themes easily ? Themes have even more "positives" ;)
Left by Grim on Aug 25, 2010 4:25 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
Dance India Dance is back with a bang on Zee TV and that too in a new avatar. The first three seasons which had individual participants and gave us new dancing talents is now called ‘DID Doubles’ which means that instead of individuals, there will be couples who will perform as a team.
Left by DID Doubles on Jan 12, 2011 9:19 PM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
I think you just don't understand how Themes work.

Issue #1: You can include extra CSS files in the page itself using the LINK element.

Issue #2: Use StyleSheetTheme instead of Theme if you want the properties on a control to override the theme.

Issue #3: As I said, you can include extra style sheets in a given page if you want. And you can already include several classes per element and several CSS files per page.

Positives:

In reference to your GridView example: Most people want a consistent look-and-feel, so they DO want their GridViews to all look the same. If you don't, that's fine, but that's not the norm. CSS works the same way: you style all TABLEs to look the same. If you want each TABLE to look different, then you add a class or ID. Themes have SkinID for the same purpose.

In reference to your pre-made themes example: There are a bunch of CSS templates out there too. Just because templates exist doesn't detract from the value of CSS or Themes.

In reference to your ogranization example: Themes make you organize your files, but you do this already, so where's the problem? Can you be more specific about "odd resource reference problems"?

Extra baggage? What extra baggage? Themes are really useful in applying CSS classes to ASP.NET controls and save duplication. My GridViews all have alternating row styles, have AutoGenerateColumns="false", and have consistent EmptyDataText. My RadioButtonLists all use Vertical Flow layout. All my validators have Display="Dynamic" and CSS Class "validator". My Wizard's navigation has a "wizardNav" CSS class.

If you like typing this stuff over and over, don't use Themes. But if you see the value in extracting repeated rules into a single location (which is also what CSS does), you must see the value in Themes.
Left by ThatMatthew on Sep 30, 2011 9:32 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
Good Article...Useful for all
Left by Goswami on Jun 18, 2012 3:52 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
#1 Dubai Web design Sum Technologies (Ph: 009713322170) Web Design from top Web Design Company Dubai for website design, web development, SEO Dubai, UAE
Left by Sumtech on Sep 08, 2012 2:57 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
VMX creative studios provides Creative Photo Retouching ,3D modeling,Matte Painting,Creative Illustration,Creative Imagery,digital photo retouching,2D Illustrator,Digital painting in dubai and etc....
Left by VMX Creative Studio Dubai on May 11, 2013 5:38 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
Laundry group - offers a professional laundry services dubai,Corporate laundry services,industrial laundry services,Laundry outsource dubai,UAE

Corporate laundry services dubai
Left by Laundry on Jul 01, 2013 5:39 AM

# re: ASP.NET Themes or CSS - Pick one
Requesting Gravatar...
To Find a Latest Gadgets Price ,Features, specifications of mobile phones,Computer &laptops,Accessories,gaming gagets,all electronic gadgets..etc

Egadgetsguru.com
Left by Egadgetsguru on Sep 28, 2013 11:56 AM

Your comment:
 (will show your gravatar)


Copyright © Andy Johns | Powered by: GeeksWithBlogs.net