asp.net ListView交替背景顏色實(shí)現(xiàn)代碼
<tr style="<%# (Container.DisplayIndex%2==0)?"background-color:white;":"background-color:#EEEEEE;" %>">
另外還有直接用js處理整個(gè)頁(yè)面中所有tr的交替色:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>全選并改變TR顏色</title>
<script language="JavaScript" type="text/javascript" for="checkbox" event="onclick"><!--
tr_bgcolor(this);
// --></script>
<script language="JavaScript" type="text/javascript"><!--
function tr_bgcolor(c){
var tr = c.parentNode.parentNode;
tr.rowIndex % 2 == 0 ? tr.style.backgroundColor = c.checked ? '#add6a6' : '#eee' : tr.style.backgroundColor = c.checked ? '#add6d6' : '';
}
function selall(obj){
for (var i=0; i<obj.form.elements.length; i++)
if (obj.form.elements[i].type == 'checkbox' && obj.form.elements[i] != obj){
obj.form.elements[i].checked = obj.checked;
tr_bgcolor(obj.form.elements[i]);
}
}
// --></script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#888888">
<tr><td><input name="selectall" type="checkbox" value="全選" onclick="selall(this)" /></td></tr>
<tr><td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr style="background-color:#eee;" style="background-color:#eee;"><td width="6%"><input type="checkbox" name="checkbox" /></td><td width="94%">***********************</td></tr>
<tr><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr style="background-color:#eee" style="background-color:#eee"><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr style="background-color:#eee" style="background-color:#eee"><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr style="background-color:#eee" style="background-color:#eee"><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
<tr style="background-color:#eee" style="background-color:#eee"><td><input type="checkbox" name="checkbox" /></td><td>***********************</td></tr>
</table>
</td></tr>
</table>
</form>
</body>
</html>
或
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>表格行tr顏色交替</title>
<style><!--
#ab{border-collapse:collapse;width:800px;margin:10px auto;}
#ab td{border:1px solid #ccc;border-top:none;padding:4px;text-align:center;}
.tr1{background-color:#eee;color:red;}
.tr2 {background-color:#ccc;color:blue;}
--></style><style bogus="1">#ab{border-collapse:collapse;width:800px;margin:10px auto;}
#ab td{border:1px solid #ccc;border-top:none;padding:4px;text-align:center;}
.tr1{background-color:#eee;color:red;}
.tr2 {background-color:#ccc;color:blue;}</style>
<script type="text/javascript"><!--
function colortd(ob) {
obob=ob.rows;
for(var i=0;i<ob.length;i++) {
if(i%2) ob(i).className="tr1";
else ob(i).className="tr2";
}
}
// --></script>
</head>
<body onload="colortd(ab)">
<table id="ab">
<tr><td>hang------------1</td></tr>
<tr><td>hang------------2</td></tr>
<tr><td>hang------------3</td></tr>
<tr><td>hang------------4</td></tr>
</table>
</body>
</html>
- asp.net GridView控件中模板列CheckBox全選、反選、取消
- asp.net Repeater取得CheckBox選中的某行某個(gè)值的c#寫(xiě)法
- 在asp.net中實(shí)現(xiàn)datagrid checkbox 全選的方法
- asp.net gridview中用checkbox全選的幾種實(shí)現(xiàn)的區(qū)別
- asp.net 獲取Datalist中Checkbox的值的小結(jié)
- WPF的ListView控件自定義布局用法實(shí)例
- asp.net ListView 數(shù)據(jù)綁定
- ASP.NET中ListView(列表視圖)的使用前臺(tái)綁定附源碼
- ASP.NET筆記之 ListView 與 DropDownList的使用
- WPF實(shí)現(xiàn)帶全選復(fù)選框的列表控件
相關(guān)文章
ASP.Net Core基于EF6、Unitwork、Autofac實(shí)現(xiàn)Repository模式
這篇文章介紹了ASP.Net Core基于EF6、Unitwork、Autofac實(shí)現(xiàn)Repository模式的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-02-02Visual Studio Debug實(shí)戰(zhàn)教程之基礎(chǔ)入門(mén)
這篇文章主要給大家介紹了關(guān)于Visual Studio Debug實(shí)戰(zhàn)教程之基礎(chǔ)入門(mén)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-09-09.NET Core3.0創(chuàng)建Worker Services的實(shí)現(xiàn)
這篇文章主要介紹了.NET Core3.0創(chuàng)建Worker Services的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10asp.net 仿騰訊微薄提示 還能輸入*個(gè)字符 的實(shí)現(xiàn)代碼
asp.net 仿騰訊微薄提示 還能輸入*個(gè)字符 的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-10-10.Net Core學(xué)習(xí)教程之在Mvc中簡(jiǎn)單的使用日志組件
這篇文章主要給大家介紹了關(guān)于.Net Core學(xué)習(xí)教程之在Mvc中簡(jiǎn)單使用日志組件的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2018-06-06ASP.NET?Core中MVC模式實(shí)現(xiàn)路由二
這篇文章介紹了ASP.NET?Core中MVC模式實(shí)現(xiàn)路由的方法,文中通過(guò)示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-04-04IE10下Gridview后臺(tái)設(shè)置行高不起作用解決方法
GridView1.HeaderStyle.Height=17發(fā)現(xiàn)在IE10 中不起作用,經(jīng)過(guò)反復(fù)測(cè)試修改為e.Row.Cells[0].Height=17即可解決問(wèn)題,有類(lèi)似問(wèn)題的朋友可以參考下哈2013-04-04