[thelist] ASP.NET: accessing the style of the page inserver-sidecode?

Jason Handby jasonh at corestar.co.uk
Tue Sep 30 03:03:18 CDT 2003


Hi Ken,


> Hmmm, what exactly do you want to change? The style of a
> particular element
> or control. Or the stylesheet that's actually being served?

Sorry, I wasn't very clear. I want to change the stylesheet that's actually
being served. I'm trying to add ".noprint { display:none; }" if the page is
being loaded in "printer-friendly" mode (as determined by my server-side
code).

What I'm currently doing is using a script tag in the aspx file:

	<style type="text/css"><% = myStyle %></style>

But I'd rather not have script tags in my aspx (being the born-again
code-behind purist that I am!)

Another alternative I've used in another project is to have an external
stylesheet that's actually an aspx file:

	<LINK href="css/dynamic.aspx" type="text/css" rel="stylesheet">

But in this case I only actually want to inject one style class, so I'd
rather not go to all the hassle of doing that.

I've been looking at the server-side object model and I can't actually see
any way of getting at anything in the <head> section of a document from
server-side code. Am I missing something?


J



More information about the thelist mailing list