zoukankan
html css js c++ java
GridView鼠标移动行变色
方法一:
在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
"
);
}
}
查看全文
相关阅读:
简单探讨spring整合mybatis时sqlSession不需要释放关闭的问题
男人常做俯卧撑,谁还敢说不行!
五大穴位
实战c++中的vector系列--vector的一些异常
[Canvas画图] 藏图阁(16) 人体穴位
算法题:剔除字符串(非常有意思)
怎样在win8系统下建立wifi热点
【code】flex_进度条样式
使用bbed改动数据
Go语言核心之美 3.2-slice切片
原文地址:https://www.cnblogs.com/juan/p/1424642.html
最新文章
POJ 3268 Silver Cow Party(最短路)
POJ 1791 Heavy Transportation(最大生成树)
POJ 2253 Frogger(最小生成树)
【POJ2387】Til the Cows Come Home (最短路)
manacher算法
【USACO09OCT】热浪Heat Wave
【POJ 3401】Asteroids
【NOIP2006】能量项链
【洛谷3047】[USACO12FEB]附近的牛Nearby Cows
【HDU1711】Number Sequence
热门文章
【HDU1754】I hate it!
【HAOI2009】毛毛虫
【洛谷2014】选课
为什么可以Ping通IP地址,但Ping不通域名?
深入剖析JDK动态代理源码实现
反射和动态代理性能对比
利用Spring AOP自定义注解解决日志和签名校验
Spring的AOP面向切面编程
Spring核心AOP(面向切面编程)总结
Spring AOP高级——源码实现(1)动态代理技术
Copyright © 2011-2022 走看看