zoukankan      html  css  js  c++  java
  • e.Row.Attributes.Add

    其实看到属性这个单词,还有点发憷呢,C#里面有个关键词是Attributes, 搞了半天貌似没有弄清楚

    e.Row.Attributes.Add()函数的介绍,包括参数,什么是Attributes

    就是往行里面添加属性
    相当于html里面的一个表里的一个行的属性,你看看那个属性有什么,这个就可以添加什么属性
    //这个就是在前台添加一个Button的按钮,然后给他添加事件
       <asp:Button ID="Button1" runat="server" Text="Button" />
     //为Button1添加onclick()事件 ,Button为服务器控件
      Button1.Attributes.Add("onclick", "return checkSame()");
    <head>
     <title></title>
        <script type="text/javascript" >
            function checkSame()
            {
                var d = document.getElementById("las");
                alert(456789)
                //d.innerText = 456;
                return 5;
            }
            document.getElementById("las45").innerHTML = checkSame();
        </script>
    </head> 
    

      


    一般用到的最多的是什么鼠标移入和移除

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { int i; //执行循环,保证每条数据都可以更新 for (i = 0; i < GridView1.Rows.Count; i++) { //首先判断是否是数据行 if (e.Row.RowType == DataControlRowType.DataRow) { //当鼠标停留时更改背景色 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'"); //当鼠标移开时还原背景色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); //点击一个当前行出现弹出框 e.Row.Attributes.Add("onclick", "alert(123)"); e.Row.Attributes.CssStyle.Add("cursor", "hand"); } } }

      然后就是add("属性","结果");

    <!DOCTYPE html>
    <html>
    <body>
    获取 js中函数的返回值
    <p>本例调用的函数会执行一个计算,然后返回结果:</p>
    
    <p id="demo"></p>
    
    <script>
    function myFunction(a,b)
    {
    return a*b;
    }
    
    document.getElementById("demo").innerHTML=myFunction(4,3);
    </script>
    
    </body>
    </html>
    

      

     这个讲的全

    C#中 Attributes的用法

     C# 中在后台给前台代码添加样式

    JS中Attribute的详解

    var d = document.getElementById("sss").setAttribute("good", "hello");
        alert(document.getElementById("t").innerHTML)
    
        var d = document.createAttribute("good");
        document.getElementById("sss").setAttributeNode(d);
        alert(document.getElementById("t").innerHTML);
    //<input type="hidden" id="sss" value="aaa" good="">

      

  • 相关阅读:
    html5 桌面提醒:Notifycations
    windows 下 apache 的虚拟主机配置
    javascript 跨域
    javascript 类型数组读取二进制数据
    javascript parseInt() 函数的进制转换陷阱
    javascript 中几个与正则表达式相关的应用
    javascript 中的二进制运算
    一段小代码,发布网页时为js 、css 文件加上版本号
    base64 编码及解码
    PHP 的比较运算与逻辑运算
  • 原文地址:https://www.cnblogs.com/ZkbFighting/p/9248279.html
Copyright © 2011-2022 走看看