user3086751
user3086751

Reputation: 205

change page css file on load

I have the code below on my master page of my asp.net c# application, which is the link to my sites CSS class, i would like to know how I would change css file on the click of a hyperlink below when the new page loads.

Currenty Css file

<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />

Link

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "intro.aspx?subjectid=" + Eval("subjectid") %>'><asp:Label ID="Label1" runat="server" ClientIDMode="Static"></asp:Label></asp:HyperLink> 

Upvotes: 1

Views: 1710

Answers (1)

user3636426
user3636426

Reputation: 177

this can be done using the below method in the page load method of the site.

HtmlLink subcss = new HtmlLink();
        subcss.Href = name of css file as sting;
        subcss.Attributes.Add("rel", "stylesheet");
        subcss.Attributes.Add("type", "text/css");
        Page.Header.Controls.Add(subcss);

Upvotes: 1

Related Questions