I have a page in my application where i need to load two css files dynamically based on the user who is logging in.
How can I load two css files in a single page dynamically?
This is my code to generate the css dynamically:
This is my code:
HtmlLink objCSS = new HtmlLink();
objCSS.Attributes.Add("href", "Includes/css/ADxMenuEmbed.css");
objCSS.Attributes.Add("rel", "stylesheet");
objCSS.Attributes.Add("type", "text/css");
Header.Controls.Add(objCSS);
Can anyone provide some ideas or samples to solve this problem?
You can load the sheet in the Code Behind like @June suggests or you can load it in the aspx itself using inline code (frowned upon by some, but since a css file is layout logic I prefer to do it this way)
If you always load the second style sheet, just that you load a different one per user you could write something like this inside the head tag of your aspx page.
if you only put the style sheet in sometimes you can write this