1. add a CSS 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 external CSS style sheets: 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 3AA. 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 4The following method has not been tried. I wonder if protected void page_onload (Object sender, eventargs e) {page. stylesheettheme = "../CSS/infomore.css";} can be used ";}
Method 5Page: <link href = "" rel = "stylesheet" type = "text/CSS" id = "CSS" runat = "server"/> Background: this.css. href = "CSS file path ";
Export this.css. atrributes ["href"] = "CSS file path ";