protected void Page_Init(object sender, EventArgs e) { HtmlLink css = new HtmlLink(); css.Href = "css/fancyforms.css"; css.Attributes["rel"] = "stylesheet"; css.Attributes["type"] = "text/css"; css.Attributes["media"] = "all"; Page.Header.Controls.Add(css); }
A expert on system architect with full SDLC and Agile development experience. Skills: , C# C++ Scrum OOA/OOD javascript ASP.Net MVC XML, HTML Web Service, RESTful, WCF, Android and etc. Email me if you need help on development.
Thursday, 8 September 2011
Dynamically add CSS file to ASP.Net page
Programmatically include CSS file to ASP.Net page is considerable simple. Add follow code to your page initialization event. Next time when page was loaded, reference to your css file will be added at runtime.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment