日期:2014-05-17  浏览次数:20629 次

Repeater控件中嵌套的table,实现单击行变色和单击行弹出页面
1,单击第一行变色,然后点击第二行时,第一行恢复到初始颜色,第二行变色..前提是我不知道有多少行.每行都要实现这种效果
2.单击某行时 不仅变色,而且会弹出页面.

------解决方案--------------------
JScript code

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,"","");
}

------解决方案--------------------
参照
http://dotnet.aspx.cc/file/Change-GridView-Row-Background-Color-When-Click-Row.aspx
做法类似
------解决方案--------------------
JScript code

/// <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"); 调用

------解决方案--------------------
楼主在否 我写了段JS给你用