GibbsUSA.net Blogs  

Wednesday, September 08, 2010

 Logon   Back to Blog   Blogs Home   GibbsUSA.net Home  


Archives
 Home... 
 May 2008 (1) 
 August 2007 (2) 
 December 2006 (1) 
 October 2006 (5) 
 

Leave your comments...

8/14/2007 11:16 AM: Add a CSS header dynamically...

GibbsUSA.net smilie: smile With the increased use of Master pages etc, I had the need to add the CSS stylesheet dynamically depending on the situation.

Putting the following code in the Page_Load event of the individual page solved the problem:


// add the stylesheet..
HtmlHead myHeader = (HtmlHead)this.Page.Header;
if (theHeader != null)
{
HtmlLink myCSS = new HtmlLink();
myCSS.Attributes.Add("href", "admin/td_codes.css");
myCSS.Attributes.Add("rel", "stylesheet");
myCSS.Attributes.Add("type", "text/css");
theHeader.Controls.Add(myCSS);
}
Print >>> EMail >>>

Comments:
Please log on to the GibbsUSA site to post comments...

 


CLR v2.0.50727.3053


Please see the site Terms And Conditions and the site Privacy Statement.
This entire web site (and the software contents therein) is Copyright © Chris Gibbs 2000-2010.
Any reproduction or copying is expressly forbidden without the prior consent of Chris Gibbs.
For more information, please contact the site WebMaster (WebMaster@GibbsUSA.net).