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
"
);
}
}
查看全文
相关阅读:
博客搬家
把本地jar上传到本地仓库命令
JAVA8的parallelStream
关于java多线程
Logger.getLogger()和LogFactory.getLog()的区别
简单实现Linux服务器重启后自动启动Tomcat以及MongoDB
【原创】JavaFx程序解决Jupyter Notebook导出PDF不显示中文
【现学现卖】th:href标签动态路径设置,thymeleaf获取session中的属性值
【现学现卖】python小爬虫
HTML5内嵌文本编辑器
原文地址:https://www.cnblogs.com/williamwindy/p/1368192.html
最新文章
FOTA-车端测试,浅说实车与台架仿真方案
Protocol Buffers Guide(for Python)
解决pip install 命令行安装包链接失败的问题
如何通过CANdb++创建一个新的DBC(二)
如何通过CANdb++创建一个新的DBC(一)
Python yield 的基本概念和用法
测试用例设计方法与举例说明
【Python 解决错误】selenium.common.exception.WebDriverException
win 10安装应用程序提示Error 1317的解决方法
CAN2.0A帧格式 与 LIN帧格式 简单说明
热门文章
Nginx 函数解析之ngx_http_get_forwarded_addr_internal
Nginx 日志切割后无法记日志
汇编 字符串字母首位转大写
Nginx 编译设置模块执行顺序
[翻译] MaxMind DB 文件格式规范
解决VC编译的DLL要安装对应运行环境否则无法使用的问题
Lua 调用C模块DLL失败
Lua 协程和线程区别
Win7x64易语言调试进程无法退出
Lua报unexpected symbol near错误
Copyright © 2011-2022 走看看