views:

96

answers:

1

I've got the following Setup in my Theme:

  • \App_Themes\Default\StyleSheet.css
  • \App_Themes\Default\PrintStyleSheet.css

The PrintStyleSheet.css file has a set of printing css rules set in them wrapped in an @Media Print { } block.

I need a way to programmatically remove the PrintStyleSheet.css from the list of css files for ASP.NET to inject based on some flags. (Some instances we want to print the site verbatim without custom formatting).

I know i could build a seperate theme without the PrintStyleSheet.css in it and switch the theme programmatically, however this would introduce duplication of my master stylesheet which is not acceptable.

Any ideas?

A: 

So, the way you are looking at it seems ad hoc. Instead of adding or removing a stylesheet after the fact, why not programmatically determine which style sheet gets rendered to begin with? Build a simple user control that checks the parameters which determine which css files get added. You could also override the theme engine (I'm not sure what class this is off the top of my head but I'm sure it's on msdn) if you want to. The last solution would be to do it client side with javascript, although javascript in webforms can be a pain..

ASP.NET Life Cycle Events: http://www.biotransfer.ca/portfolio/McGill-MUHC/aspnet-life-cycles-events.pdf

Settings a theme programmatically: http://msdn.microsoft.com/en-us/library/ms366514%28v=VS.100%29.aspx

smartcaveman
So what you're suggesting is ditching the `Theme System` All together and just doing my own `<link />` tags?
Aren