zoukankan
html css js c++ java
可以变换图像的ImageButton
项目中。我们经常需要一个当鼠标移过去就可以变换图像,离开又恢复到原来图像的控件,
也许大家都会说easy 但是这个写多起来也是比较郁闷。所以我们还是自己来写一个控件
internal
sealed
class
WebCategoryAttribute : System.ComponentModel.CategoryAttribute
{
internal
WebCategoryAttribute(
string
category)
:
base
(category)
{
}
}
//
class WebCategoryAttribute
/**/
///
<summary>
///
Summary description for MyImageButton
///
</summary>
public
class
MyImageButton : ImageButton
{
[Editor(
"
System.Web.UI.Design.ImageUrlEditor, System.Design, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
"
,
typeof
(System.Drawing.Design.UITypeEditor))]
[DefaultValue(
""
)]
[WebCategoryAttribute(
"
Appearance
"
)]
[Bindable(
true
)]
public
string
HoverImageUrl
{
get
{
string
text
=
(
string
)
this
.ViewState[
"
HoverImageUrl
"
];
if
(text
!=
null
)
{
return
text;
}
return
string
.Empty;
}
set
{
this
.ViewState[
"
HoverImageUrl
"
]
=
value;
}
}
protected
override
void
AddAttributesToRender(HtmlTextWriter writer)
{
if
(HoverImageUrl.Length
!=
0
)
{
base
.Attributes.Add(
"
onmouseover
"
,
string
.Format(
"
this.src=\
"
{
0
}
\
""
,
base
.ResolveUrl(HoverImageUrl)));
base
.Attributes.Add(
"
onmouseout
"
,
string
.Format(
"
this.src=\
"
{
0
}
\
""
,
base
.ResolveUrl(ImageUrl)));
}
base
.AddAttributesToRender(writer);
}
public
MyImageButton()
{
}
}
}
很简单就可以搞定了。 比较复杂的地方是。HoverImageUrl 你必须为它指定一个Editor
查看全文
相关阅读:
【解决】Word中插入图片后变模糊(失真)
【解决】Windows文件夹没有边框
【解决】电脑字体突然显示不正常
NLP与深度学习(六)BERT模型的使用
NLP与深度学习(五)BERT预训练模型
NLP与深度学习(四)Transformer模型
NLP与深度学习(三)Seq2Seq模型与Attention机制
用ByteArrayOutputStream解决IO流乱码问题
在vue3中使用vue-property-decorator报错
python之批量打印网页为pdf文件(二)
原文地址:https://www.cnblogs.com/lovebanyi/p/897460.html
最新文章
哈哈哈哈
mysql查看bin_log
1111
事务属性的7种传播行为
Spring事务传播行为详解(有场景)
Mybatis 面试题
JVM中的类加载机制
事务管理
说一下Mysql索引
数据库使用宝典
热门文章
架构设计之数据库设计
Pandas-reindex中关于填充缺失值的几个方法
Python去除小数点后面多余的0
pyecharts离线使用说明
pyppeteer离线环境配置
ROS2 第四讲 tf2
ROS2 第三讲 基本操作
重装电脑系统教程
H.264 编解码
CentOS 7 下GeoServer 2.18.0 安装和配置
Copyright © 2011-2022 走看看