Thursday, June 14, 2012

How to: Add CSS file in ASP.NET at runtime

Adding CSS file in ASP.NET programatically

HtmlGenericControl si = new HtmlGenericControl();
si.TagName = "link";
si.Attributes.Add("type", "text/css");
si.Attributes.Add("href", "css/module.css");
si.Attributes.Add("rel", "stylesheet");
this.Page.Header.Controls.Add(si);


2 comments:

  1. This is a simple ASP.NET code to what I have seen before in one forum being used for the same purpose. That was really confusing and didn't understand what exactly it want to say. This code is really easy to follow and even understable to what it means.

    ReplyDelete
  2. Hi, thanks for sharing. That is very simple piece of code. If you want to get such simple solutions, just call this guys https://www.jitbit.com/. I'm sure they will help you.

    ReplyDelete