loading 2 css files in page load

I have an asp.net with master page and content pages.

I have a master.css file that I want to load with the masterpage each time. I have separate css pages that go with the content pages. I would like to load these (add them to the master page) in the page_load event of the content page.

Is there a way to do this?  I tried the below but it seems to replace the masterpage's css file and not load both as I intend.


protected void Page_Load(object sender, EventArgs e)
        {
              
            this.Header.InnerHtml = "<LINK href='Customer.css' type='text/css' rel='stylesheet'>";

        }

Open in new window

rutledgjAsked:
Who is Participating?
 
rutledgjConnect With a Mentor Author Commented:
I found a solution here:

 HtmlLink link = new HtmlLink();
            link.Attributes.Add("type", "text/css");
            link.Attributes.Add("rel", "stylesheet");
            link.Attributes.Add("href", "~/Customer.css");
            this.Header.Controls.Add(link);
0
 
rajvjaConnect With a Mentor Commented:
Hi,

  Define a theme(Ex: Default)
Put all your css in this folder.

set the theme in web.config
<Pages theme="Default"/>

0
 
rutledgjAuthor Commented:
Thanks but thats not what I'm trying to accomplish. I just want to be able to have two css files. One for the master page and one for the content page.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.