Wednesday, November 05, 2008

ASP.Net - Dynamically Adding a CSS/StyleSheet Reference at run-time

Per Michael, I have removed a technique that was only available in Beta 1.

protected void Page_Init(object sender, EventArgs e)
   HtmlLink link = new HtmlLink();
   link.Href = "~/StyleSheet.css";
   link.Attributes.Add("rel", "stylesheet");
   link.Attributes.Add("type", "text/css");


Rem said...

The blog is helpfull...
visit also example

Michael Freidgeim said...

LinkedStyleSheets was available only in Beta (see, so the first method is WRONG.