当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net 动态引用样式表代码

asp.net 动态引用样式表代码

2017年12月12日  | 移动技术网IT编程  | 我要评论

铁路职工论坛,修真神偷txt下载,马蜂窝三国杀

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"; //页面加载时赋值 }
}
aa.aspx <link href="<%=m_stylesrc%>" type="text/css" rel="stylesheet">
方法4 下面这个方法没试过,不知是否能用
protected void page_onload(object sender, eventargs e) {
page.stylesheettheme = "../css/infomore.css";
}
方法5 页面:
<link href="" rel="stylesheet" type="text/css" id="css" runat="server"/>
后台
this.css.href = "css文件路径";

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网