zoukankan
html css js c++ java
转:GridView鼠标移动行变色 (http://www.cnblogs.com/lovenets/articles/808071.html)[同ceng]
方法一:
在GridView的
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Attributes.Add(
"
onMouseOver
"
,
"
SetNewColor(this);
"
);
e.Row.Attributes.Add(
"
onMouseOut
"
,
"
SetOldColor(this);
"
);
}
}
在页面中加入
<
SCRIPT language
=
javascript
>
var _oldColor;
function SetNewColor(source)
{
_oldColor
=
source.style.backgroundColor;
source.style.backgroundColor
=
'
#666666
'
;
}
function SetOldColor(source)
{
source.style.backgroundColor
=
_oldColor;
}
</
SCRIPT
>
方法二:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Attributes[
"
onMouseOver
"
]
=
"
js.ItemOver(this)
"
;
}
}
在页面上加入
<
SCRIPT language
=
javascript type
=
text
/
javascript
>
var js
=
new
function()
{
if
(
!
objbeforeItem)
{var objbeforeItem
=
null
;var objbeforeItembackgroundColor
=
null
;}
this
.ItemOver
=
function(obj)
{
if
(objbeforeItem)
{objbeforeItem.style.backgroundColor
=
objbeforeItembackgroundColor;}
objbeforeItembackgroundColor
=
obj.style.backgroundColor;
objbeforeItem
=
obj;
obj.style.backgroundColor
=
"
#fcfcfc
"
;
}
}
</
SCRIPT
>
方法三:
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
//
鼠标移动到每项时颜色交替效果
e.Row.Attributes.Add(
"
OnMouseOut
"
,
"
this.style.backgroundColor='White';this.style.color='#003399'
"
);
e.Row.Attributes.Add(
"
OnMouseOver
"
,
"
this.style.backgroundColor='#6699FF';this.style.color='#8C4510'
"
);
//
设置悬浮鼠标指针形状为"小手"
e.Row.Attributes[
"
style
"
]
=
"
Cursor:hand
"
;
}
}
//
----------------------------------------
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
//
判断是否是DataRow,以防止鼠标经过Header也有效果
{
e.Row.Attributes.Add(
"
onmouseover
"
,
"
e=this.style.backgroundColor; this.style.backgroundColor='#cccccc'
"
);
e.Row.Attributes.Add(
"
onmouseout
"
,
"
this.style.backgroundColor=e
"
);
}
}
查看全文
相关阅读:
Xtrabackup的安装
在 CentOS 7上Virtualbox+phpVirtualBox完整虚拟化环境部署
用分离、附加的方式实现sql server数据库的备份和还原
Oracle 11g透明网关连接Sqlserver
硬盘SMART检测参数详解[转]
安装了 R2 Integration Servic 之后,SQL Server 2008 Management Studio报错
jenkins获取git上的源码
CentOS7配置防火墙
CentOS 7 安装 Oracle 11.2.0.4
oralce 11.2.0.4手动创建EM
原文地址:https://www.cnblogs.com/williamwindy/p/1368192.html
最新文章
Lucene基础
Redis】Java中使用Jedis操作Redis(Maven导入包)、创建Redis连接池
java字符串的替换replace、replaceAll、replaceFirst的区别详解
java写桌面程序
python两个 list 获取交集,并集,差集的方法
java 获取当天(今日)零点零分零秒
Xcode Search Paths 选项配置
iOS 报错信息: dyld: Library not loaded: @rpath/XCTest.framework/XCTest Referenced from
IntelliJ IDEA2018.3 最新破解方法
iOS 初探代码混淆(OC)
热门文章
iOS 底层解析weak的实现原理(包含weak对象的初始化,引用,释放的分析)
Git 忽略提交 .gitignore
iOS启动速度优化
加载高清大图崩溃问题
iOS 性能优化总结
AutoLayout的坑
test markdown
【一天一个shell命令】【cut】
mysql数据库全备和全备还原(使用Xtrabackup)
Xtrabackup简介
Copyright © 2011-2022 走看看