gridview 鼠标经过改变颜色

来源:互联网 发布:网络安全法考试题 编辑:程序博客网 时间:2024/06/02 22:01

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");
            e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");
        }
    }

 

<script type="text/javascript">
         var _oldColor;  
       function SetNewColor(source)  
       {  
          _oldColor=source.style.backgroundColor;  
          source.style.backgroundColor='#FFFF99';  
            
       }  
       function SetOldColor(source)  
       {  
         source.style.backgroundColor=_oldColor;  
       }  

    </script>