把Girdview鼠标经过时行变色应用到所有页面
时间:2010-10-28 来源:潇客的技术博客

function GridViewColor(GridViewId) {
//获取所有要控制的行
var AllRows = document.getElementById(GridViewId);
if (AllRows != null) {
AllRows = AllRows.getElementsByTagName("tr");
//设置每一行的背景色和事件,循环从1开始而非0,可以避开表头那一行
for (var i = 1; i < AllRows.length; i++) {
AllRows[i].onmouseout = function() { this.style.background = "#FFFFFF"; }
}
}
}
引用这段JS,只要在每个页面的Page_Load中注册即可,ctl00_PageBody_gvItems为GirdView的客户端ID
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "js", "GridViewColor('ctl00_PageBody_gvItems');", true);
相关阅读 更多 +