zoukankan      html  css  js  c++  java
  • Change GridView RowColor OnMouseClick

    原文地址http://gridviewguy.com/ArticleDetails.aspx?articleID=174

    AzamSharp上一篇文章类似,只是触发的事件是onclick而不再是onmouseover

    主要代码如下:

    服务器端代码:
     protected void MyGridView_RowCreated(object sender, GridViewRowEventArgs e)

    {

    string rowID = String.Empty;

    if (e.Row.RowType == DataControlRowType.DataRow)

    {

    rowID = "row"+e.Row.RowIndex;

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

    e.Row.Attributes.Add("onclick","ChangeRowColor(" +"'" + rowID + "'" + ")");

    }

    }

    javascript教本:
    <script language ="javascript" type="text/javascript">

    document.body.style.cursor = 'pointer';

    var oldColor = '';

     

    function ChangeRowColor(rowID)

    {

    var color = document.getElementById(rowID).style.backgroundColor;

    if(color != 'yellow')

    oldColor = color;

    if(color == 'yellow')

    document.getElementById(rowID).style.backgroundColor = oldColor;

    else document.getElementById(rowID).style.backgroundColor = 'yellow';

    }

    </script>

  • 相关阅读:
    编译安装LEMP
    eAccelerator配置和使用指南
    /dev/null的用途
    分库分表
    JVM
    SOFA 数据透析
    HTTPS
    SOFA 通信
    分布式锁
    mysql 锁
  • 原文地址:https://www.cnblogs.com/stswordman/p/467320.html
Copyright © 2011-2022 走看看