To add CSS Stylesheeet file programatically to ASPX page we can use .NET HtmlLink class in the Page_Init event handler:
protected void Page_Init(object sender, EventArgs e) { // Define an HtmlLink control. HtmlLink myHtmlLink = new HtmlLink(); myHtmlLink.Href = "~/StyleSheet.css"; myHtmlLink.Attributes.Add("rel", "stylesheet"); myHtmlLink.Attributes.Add("type", "text/css"); // Add the HtmlLink to the Head section of the page. Page.Header.Controls.Add(myHtmlLink); }
No comments:
Post a Comment