asp.net dynamic referencing style sheet code _ Practical Tips

Source: Internet
Author: User
1. Add 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. CSS style sheet outside the link: 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 variables, style file path
private void Page_Load (object sender, System.EventArgs e) {
M_STYLESRC = ".. /xxx.css "; Assignment on page load}
}
Aa.aspx <link href= "<%=m_StyleSrc%>" type= "Text/css" rel= "stylesheet" >
Method 4 The following method has not been tried, I do not know whether 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";
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.