您的位置:首页 > Web前端 > JavaScript

给GridView里的行加上鼠标滚动效果

2008-11-19 17:56 267 查看
 

protected void gv_Main_RowDataBound(object sender, GridViewRowEventArgs e)

        {

            e.Row.Attributes.Add("id", "tr_" + e.Row.RowIndex.ToString());

            e.Row.Attributes.Add("onmouseover", "onmouse(/"" + "tr_" + e.Row.RowIndex.ToString() + "/")");

            e.Row.Attributes.Add("onmouseout", "mouseout(/"" + "tr_" + e.Row.RowIndex.ToString() + "/")");

        }

 

<script language="javascript" type="text/javascript">

var orgColor;

function onmouse(rowId)

{

    var myRow = document.getElementById(rowId);

    orgColor = myRow.style.backgroundColor;

    myRow.style.backgroundColor= "Red";

    myRow.align = "center";

}

function mouseout(rowId)

{

    var myRow = document.getElementById(rowId);

    myRow.style.backgroundColor= orgColor;

    myRow.align = "left";

}

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  javascript
相关文章推荐