Dynamic reference style sheet Asp.net

Source: Internet
Author: User

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 ";

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.