用户控件里的CSS该如何定义 .
2013-02-21 10:34
471 查看
2010-03-24 18:16 625人阅读 评论(0) 收藏 举报
用户控件如果要集中定义类似
<style type="text/css">
.C {border-right:1px #D9AE7F solid;border-bottom:1px #D9AE7F solid;cursor:pointer;font-family:arial;font-weight:bold;height:23px;background:#FFF7DD none repeat scroll 0 0; line-height:20px;}
#ctem td {border-bottom:1px solid #F0F0F0;color:black;height:25px;}
#ctem a:link,#cctvitem a:active,#cctvitem a:visited {color:black;text-decoration:none;}
#ctem a:hover {color:red;text-decoration:underline;}
.TMSpan {cursor:pointer;display:inline;width:70px;margin:3px 2px 0px 2px;height:16px;border-left:1px solid #D9AE7F;border-right:1px solid #D9AE7F;border-top:1px solid #D9AE7F;text-align:center;font-weight:bold;}
</style>
这种CSS怎么办?
如果是写在控件中,不符合规范,虽然一般情况下也起作用,但如果是动态加载,如AJAX加载这个用户控件,就不行了。
如果由调用页预先写在页头,当然没问题,但控件的意义就打了折扣。
可以使用如下方法:
控件代码:
const string STYLE = @"<style type=""text/css"">
.C {border-right:1px #D9AE7F solid;border-bottom:1px #D9AE7F solid;cursor:pointer;font-family:arial;font-weight:bold;height:23px;background:#FFF7DD none repeat scroll 0 0; line-height:20px;}
#ctem td {border-bottom:1px solid #F0F0F0;color:black;height:25px;}
#ctem a:link,#cctvitem a:active,#cctvitem a:visited {color:black;text-decoration:none;}
#ctem a:hover {color:red;text-decoration:underline;}
.TMSpan {cursor:pointer;display:inline;width:70px;margin:3px 2px 0px 2px;height:16px;border-left:1px solid #D9AE7F;border-right:1px solid #D9AE7F;border-top:1px solid #D9AE7F;text-align:center;font-weight:bold;}
</style> ";
protected void Page_Load(object sender, EventArgs e)
{
//控件自有CSS
this.Page.Header.Controls.Add(new LiteralControl(STYLE));
}
这样控件的CSS就会出现在调用页的<head/>里了。
用户控件如果要集中定义类似
<style type="text/css">
.C {border-right:1px #D9AE7F solid;border-bottom:1px #D9AE7F solid;cursor:pointer;font-family:arial;font-weight:bold;height:23px;background:#FFF7DD none repeat scroll 0 0; line-height:20px;}
#ctem td {border-bottom:1px solid #F0F0F0;color:black;height:25px;}
#ctem a:link,#cctvitem a:active,#cctvitem a:visited {color:black;text-decoration:none;}
#ctem a:hover {color:red;text-decoration:underline;}
.TMSpan {cursor:pointer;display:inline;width:70px;margin:3px 2px 0px 2px;height:16px;border-left:1px solid #D9AE7F;border-right:1px solid #D9AE7F;border-top:1px solid #D9AE7F;text-align:center;font-weight:bold;}
</style>
这种CSS怎么办?
如果是写在控件中,不符合规范,虽然一般情况下也起作用,但如果是动态加载,如AJAX加载这个用户控件,就不行了。
如果由调用页预先写在页头,当然没问题,但控件的意义就打了折扣。
可以使用如下方法:
控件代码:
const string STYLE = @"<style type=""text/css"">
.C {border-right:1px #D9AE7F solid;border-bottom:1px #D9AE7F solid;cursor:pointer;font-family:arial;font-weight:bold;height:23px;background:#FFF7DD none repeat scroll 0 0; line-height:20px;}
#ctem td {border-bottom:1px solid #F0F0F0;color:black;height:25px;}
#ctem a:link,#cctvitem a:active,#cctvitem a:visited {color:black;text-decoration:none;}
#ctem a:hover {color:red;text-decoration:underline;}
.TMSpan {cursor:pointer;display:inline;width:70px;margin:3px 2px 0px 2px;height:16px;border-left:1px solid #D9AE7F;border-right:1px solid #D9AE7F;border-top:1px solid #D9AE7F;text-align:center;font-weight:bold;}
</style> ";
protected void Page_Load(object sender, EventArgs e)
{
//控件自有CSS
this.Page.Header.Controls.Add(new LiteralControl(STYLE));
}
这样控件的CSS就会出现在调用页的<head/>里了。
相关文章推荐
- 用户控件里的CSS该如何定义
- 用户控件里的CSS该如何定义
- SilverLight学习笔记--如何在xaml文件中操作用户在后台代码定义的类(2)--示例篇:创建一个登录控件(原创)(转载本文请注明出处)
- asp.net定义用户控件时,属性持久化和如何动态加载的问题
- CSS如何定义文字大小以体现用户体验_Web标准教程
- 一个aspx页面有2个按钮,都是服务器控件,服务器上的DLL如何知道用户点击了哪个按钮,从而按钮的事件函数被调用
- C#-WinForm-用户控件如何获取父级窗体
- 如何:使用 Windows 窗体 TextBox 控件创建密码文本框 .NET Framework 2.0 其他版本 密码框是一种 Windows 窗体文本框,它在用户键入字符串时显示占位符。 创
- 用户控件定义属性(C#:ASP.NET)
- [导入]Access里使用存储过程及用户自己定义的控件里使用参数
- css中标签权值是如何定义的
- 如何只授予用户查看存储过程定义的权限
- asp.net 2.0小tips:在web.config里设置用户定义控件
- 如何在用户控件中操作页面中的控件?
- VB用户控件制作讲解与实例-----用户控件属性或函数的描述信息如何写入程序
- 如何封装JS和CSS文件封装为服务器端控件---ASP.NET 2.0
- 在Vs2008中创建的用户控件,在工具栏中如何显示
- 如何把&quot;用户定义的数据类型&quot;的ower改为dbo?
- 用div+css布局,控件排布乱了,如何解决
- 用户控件上的GridView如何导入、导出到Excel表