zoukankan
html css js c++ java
自动处理过长字符串显示的Web控件
我们很多时候需要在一行上显示一段说明文字,而由于Web页面宽度的不确定性,我们任意调节其宽度后,常常搞得文字撑出页面或者折成好多行
。通过使用CSS,我们可以限制为一行的宽度,并使多余的字符隐藏。为了方便,做成一个小Web控件来使用。
using
System;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.ComponentModel;
namespace
cnblogs.birdshome.WebControls
{
/**/
///
<summary>
///
Summary description for AutoLabel.
///
</summary>
[DefaultProperty(
"
Text
"
),
ToolboxData(
"
<{0}:AutoLabel runat=server></{0}:AutoLabel>
"
)]
public
class
AutoLabel : System.Web.UI.WebControls.Label
{
protected
override
void
CreateChildControls()
{
base
.CreateChildControls ();
this
.Width
=
Unit.Percentage(
100
);
this
.Attributes[
"
onmouseover
"
]
=
"
if ( this.clientWidth < this.scrollWidth ) this.title = this.innerText; else this.title = '';
"
;
this
.Attributes.CssStyle[
"
white-space
"
]
=
"
nowrap
"
;
this
.Attributes.CssStyle[
"
overflow
"
]
=
"
hidden
"
;
this
.Attributes.CssStyle[
"
text-overflow
"
]
=
"
ellipsis
"
;
}
}
}
AutoLabel继承至Label控件,默认宽度为"100%",当把AutoLabel放入容器类元素中后,其内容的宽度受容器大小自动调整。并且当AutoLabel出现"..."号后,鼠标放在上面,其ToolTip会自动显示器完整内容。 如下图:
查看全文
相关阅读:
数据库连接池
Apache- DBUtils框架学习
权限表的设计
Java的I/O对文件的操作
Java下载文件
Java连接MySQL数据库
C#用log4net记录日志
C#多线程和线程池
C#利用反射动态调用DLL并返回结果,和获取程序集的信息
CephRGW 在多个RGW负载均衡场景下,RGW 大文件并发分片上传功能验证
原文地址:https://www.cnblogs.com/levin/p/575030.html
最新文章
openssl API网络通信
Opencv中Rect_类
opencv 基本数据结构
昆明控制器说明文档
关于虚拟机联网
utf8转unicode
unicode,ansi,utf-8,unicode big endian编码的区别
指静脉屏幕说明usart hmi
关于贝叶斯那篇论文
opencv reshape函数说明
热门文章
opencv3.2 编译安装说明
html5上传图片php特殊处理一下
正则匹配汉字
Don't know how to define struct flock on this system, set --enable-opcach=no
mysql服务常用命令
PHP时间戳是10位的,JS时间戳是13位
insert失败自动执行update(duplicate先insert)
mac 下做csv文件的读取与生成的 遇到的坑
charles
WebService简单教程
Copyright © 2011-2022 走看看