Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Re: dynamically create <style> from codebehind class


Message #1 by "Karsten Laufer" <laufer@b...> on Thu, 1 Aug 2002 13:51:02
My application serves output for several dynamically declared 
styleattributes (fonts, colors, sizes etc.). The base attribute for the 
styles are in a database. 

While rendering a page the application determines the correct and 
necessary attributes and creates the style-infos for <style></style>.
I think using a separate file (linkrel...) is not the best way because the 
online creation of this file costs performance and the dynamic creation 
process can't determine which styles are necessary in the page using it - 
btw. the style information must not be cached by filename!

I found a half working solution with <header runat=server id=eHeader> and 
adding a HTMLGenericControl with a tagname <style>. This works fine apart 
from VS.Net which sometimes removes the runat=server from the <header> 
declaration of the .aspx-file - Cant determine why and when!

> I would just create a stylesheet with format desired, and populate a 
l> iteral control placed on page with a link to the stylesheet.

> Example:
l> iteral1.text = "<LINK rel=""stylesheet"" type=""text/css"" 
h> ref=""../Stylesheets/YourStyleSheet.css"">"
[...end removed...]

  Return to Index