tags:

views:

1182

answers:

3

I'm making a website that will have to render correctly on FF/IE6/IE7/Opera/Safari. IE6 came as a late requirement (when I had done all the other browsers) and it just has to be useable, not necessarily the same as on the other browsers. Now I'm tweaking it so that it's useable on IE6 as well.

To this end I've created another stylesheet in my theme called IE6_override.css. As you might have guessed, I want it to be applied only when the browser is IE6. Conditional comments would perfect for this.

The only problem is - ASP.NET renders a <link> tag for every CSS file that is in the theme's folder, thus including this file unconditionally on all browsers.

I would like to stick to themes because it's completely feasible that we might create more skins for our application later (if the customers desire that).

Is there any way how I can make ASP.NET exclude this specific .CSS file from its auto-including?

Added: Thank you for your answers! In the end I found a workaround. Due to some other styling problems I've asked about earlier, I'm forced to have a IE6-workaround Javascript as well. Thus I prefixed all my IE6-specific rules with a .ie6_dummy class selector and then removed it in JS upon page loading. :)

+2  A: 

I don't think you can. We stopped using the App_Themes folder for exactly that reason. This also saved us having to prefix every css file with a number so they load in the right order.

Nick
+1  A: 

Indeed it's not possible to exclude a specific CSS file. However, there seem to be several workarounds located here. I'd suggest reading through those and choosing an appropriate solution (if any).

Shogun
+1  A: 

There are a couple of posts out on the web which seem to address your problem - looking for "Conditional comments in asp.net themes" I came across these which look like they may help:

  1. How to take control of style sheets in ASP.NET Themes with the StylePlaceholder and Style control
  2. Conditional stylesheets in Themes - note that the design templates refered to have moved to here

The first one will also address the media issue with theme stylesheets as well.

Zhaph - Ben Duguid