- 相關(guān)推薦
asp.net 動(dòng)態(tài)引用樣式表代碼示范
1. 添加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. 鏈接外部的CSS樣式表:
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);
方法3 aa.aspx.cs public string m_StyleSrc = string.Empty; //公共變量 ,樣式文件路徑
private void Page_Load(object sender, System.EventArgs e) {
m_StyleSrc = "../xxx.css"; //頁(yè)面加載時(shí)賦值 }
}
aa.aspx
方法4 下面這個(gè)方法沒試過,不知是否能用
protected void Page_Onload(object sender, EventArgs e) {
Page.StyleSheetTheme = "../css/infomore.css";
}
方法5 頁(yè)面:
后臺(tái)
this.css.Href = "css文件路徑";
【asp.net 動(dòng)態(tài)引用樣式表代碼示范】相關(guān)文章:
簡(jiǎn)介如何把CSS樣式表加入adobe DW08-28
數(shù)控編程代碼大全02-13
Java代碼的基本知識(shí)09-03