asp.net 动态引用样式表代码
更新时间:2009年11月28日 02:26:05 作者:
动态引用样式表代码,需要的朋友可以参考下。
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文件路径";
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文件路径";
相关文章
asp.net core 获取 MacAddress 地址方法示例
这篇文章主要介绍了asp.net core获取MacAddress地址方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2019-02-02
在jquery repeater中添加设置日期,下拉,复选框等控件
JQueryElement 更新到了 3.5.1, 今天给大家主要讲下如何在 Repeater 的模板中添加设置一些控件.2011-10-10
.net控件dropdownlist动态绑定数据具体过程分解
一、在页面初始化时候将集合绑定到DropDownList;二、在页面初始化的时候向DropDownList添加数据;三、将DataReader读取的数据动态绑定到DropDownList等等2013-05-05
ASP.NET中使用Application对象实现简单在线人数统计功能
这篇文章主要介绍了ASP.NET中使用Application对象实现简单在线人数统计功能,本文给出实现步骤和相应代码实例,需要的朋友可以参考下2015-06-06
VS2017 Cordova Ionic2 移动开发环境搭建教程
这篇文章主要为大家详细介绍了VS2017 Cordova Ionic2 移动开发环境搭建教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2017-04-04
.NET Core利用skiasharp文字头像生成方法教程(基于docker发布)
这篇文章主要给大家介绍了关于.NET Core利用skiasharp文字头像生成(基于docker发布)的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。2018-03-03
ASP.NET Core 2.0中Razor页面禁用防伪令牌验证
在这篇短文中,我将向您介绍如何ASP.NET Core2.0 Razor页面中禁用防伪令牌验证,对此有兴趣的朋友参考学习下吧。2018-01-01


最新评论