web analytics

Dynamically adding a CSS link to an ASP.NET WebForm page

Options

davegate 143 - 921
@2016-01-27 13:12:07

The following C# code adds a CSS link to the header node of an ASP.NET WebForm page.

// register css
HtmlHead head = (HtmlHead)Page.Header;
HtmlLink link = new HtmlLink();
link.Attributes.Add("href", Page.ResolveClientUrl("~/App_Themes/Default/StyleSheet.css"));
link.Attributes.Add("type", "text/css");
link.Attributes.Add("rel", "stylesheet");
head.Controls.Add(link);

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com