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会自动显示器完整内容。 如下图:
查看全文
相关阅读:
mybatis异常:org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map com.sunyan.domain.User
Markdown首行缩进和换行
mybatis入门——mybatis的概述
python2跟python3的区别
码云与git
Python入门(一)
python环境搭建
python简介
计算机基础
Typora、安装及使用
原文地址:https://www.cnblogs.com/levin/p/575030.html
最新文章
微信小程序左右滑动实现tab的切换
微信小程序的分包
centos jar包启动停止
js中数组对象去重的几种方法
MySQL批量删除相同前缀的表
采集项目之使用资料
quertz定时任务
springboot定时任务
Power Cycling Test -----AC
Power Cycling Test -----Reboot
热门文章
SD Card Study
Memory Function Test
Graphic Function Test
Common Words Used in Android
Why radio buttons are called 'radio' buttons
What is href=“#” and why is it used?
What Is the Real Name of the #?
Bootstrap Buttons
Bootstrap Button Groups
mybatis基本使用——基于代理Dao的CRUD操作
Copyright © 2011-2022 走看看