1

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> 
0

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.