62,272
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 双色表格以及光棒效果
/// </summary>
/// <param name="o">GridView的ID</param>
/// <param name="a">1 3 5 7 9 单行背景颜色</param>
/// <param name="b">2 4 6 8 10 双行背景颜色</param>
/// <param name="c">onmouseover 鼠标移动单个表格的颜色</param>
function senfe(o, a, b, c)
{
var t = document.getElementById(o)
if (t != null)
{
t = t.getElementsByTagName("tr");
for (var i = 1; i < t.length; i++)
{
t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? a : b;
t[i].onclick = function()
{
this.x = "0";
this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
}
t[i].onmouseover = function()
{
if (this.x != "1")
this.style.backgroundColor = c;
}
t[i].onmouseout = function()
{
if (this.x != "1")
this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
}
}
}
}
//senfe("g1","#ECF9FC","#FFFFFF","#D6F1F8"); 调用
var S={
tempColorValue: { sBgColor: null, item_id: null, sColor: null, tempButtonBgColor: null },
changeBgColor: function(obj) { /*鼠標經過時的背景色*/
if (obj.id != this.tempColorValue.item_id) {
this.tempColorValue.sBgColor = obj.style.backgroundColor;
this.tempColorValue.sColor = obj.style.color;
obj.style.cursor = "pointer";
obj.style.backgroundColor = "#d0f3ff";
}
},
clearBgColor: function(obj) { /*鼠標離開后的背景色*/
if (obj.id != this.tempColorValue.item_id) {
obj.style.backgroundColor = this.tempColorValue.sBgColor;
obj.style.color = this.tempColorValue.sColor;
}
},
setBgColor: function(obj) { /*設置當前元素的背景色*/
obj.style.backgroundColor = "#3E94F1";
obj.style.color = "#fff";
var item_id = this.tempColorValue.item_id;
if (item_id != null) {
$(item_id).style.backgroundColor = this.tempColorValue.sBgColor; ;
$(item_id).style.color = this.tempColorValue.sColor;
}
if (item_id == obj.id) {
this.tempColorValue.item_id = null;
}
else {
this.tempColorValue.item_id = obj.id;
}
}
}
function Show(obj){
var url = "xxx.aspx?a="+obj;
window.showModalDialog(url,"","");
}
Repeater_DataBound:
e.Item.Attributes.Add("id",e.Item.ItemIndex.ToString());
e.Item.Attributes.Add("onclick","S.setBgColor(this);Show('001')");
e.Item.Attributes.Add("onmouseover","S.changeBgColor(this)");
e.Item.Attributes.Add("onmouseout","S.clearBgColor(this)");
<tr onclick='CChange(<%# Eval("ID")%>,<%# Container.ItemIndex.ToString() %>)' id='<%# "tr"+Container.ItemIndex.ToString() %>'></tr>
<script type="text/javascript" language="javascript">
var num=false;
var curID=-1;
function CChange(id,showid)
{
if(curID==-1)
{
document.getElementById("tr"+showid).style.backgroundColor="#CCCCCC";
window.open('');
}
else
{
if(curID!=showid && curID!=-1)
{
document.getElementById("tr"+curID).style.backgroundColor="#FFFFFF";
num=false;
}
curID=showid;
if(!num)
{
num=true;
document.getElementById("tr"+curID).style.backgroundColor="#CCCCCC";
window.open();
}
}
}
</script>