1. Add a CSS Style: style Style = new Style ();
Style. ForeColor = System. Drawing. Color. Navy;
Style. BackColor = System. Drawing. Color. LightGray;
This. Header. StyleSheet. CreateStyleRule (style, null, "body ");
2. link the external CSS style sheet: HtmlLink link = new HtmlLink ();
Link. Attributes. Add ("type", "text/css ");
Link. Attributes. Add ("rel", "stylesheet ");
Link. Attributes. Add ("href ","~ /Newstyle.css ");
This. Header. Controls. Add (link );
Method 3 aa. aspx. cs public string m_StyleSrc = string. Empty; // public variable, Style File Path
Private void Page_Load (object sender, System. EventArgs e ){
M_StyleSrc = "../xxx.css"; // value assigned during page loading}
}
Aa. aspx <LINK href = "<% = m_StyleSrc %>" type = "text/css" rel = "stylesheet">
Method 4: I have not tried the following method. I wonder if it can be used.
Protected void Page_Onload (object sender, EventArgs e ){
Page. StyleSheetTheme = "../css/infomore.css ";
}
Method 5 page:
<Link href = "" rel = "stylesheet" type = "text/css" id = "css" runat = "server"/>
Background
This.css. Href = "css file path ";