Changing the stylesheet in the code on the main page

In a convenient page, I set up a stylesheet that defines the layout.

 <link id="layoutStylesheet" href="CSS/Layout3Col.css" rel="stylesheet" type="text/css" runat="server" />

I have a ShowDoc.aspx page that inherits the main page.
I want to load another css file when a specific parameter is passed to ShowDoc.aspx in the query string.

How can i do this?
Do I have to define a public property on the main page so that showDoc.aspx can access it and change the layoutStylesheet?

+3
source share
3 answers

You can find a link to the stylesheet using the "Wizard" property on the ShowDoc page in Page_Load and override the HREF property there.

HtmlLink link = Page.Master.FindControl( "layoutStyleSheet" ) as HtmlLink;
link.Href = ...your chosen stylesheet...
+9

, Form_Load :

switch (Request["whateverstyle"]) {
    case "style1" : layoutStylesheet.Attributes["href"] = "style1.css";
    case "style2" : layoutStylesheet.Attributes["href"] = "style2.css";
    ...
}
0

, , , -.

root doctype/html/head/body ; "" - . -.

, ContentPlaceHolder , HEAD.

0

Source: https://habr.com/ru/post/1714665/


All Articles