其实看到属性这个单词,还有点发憷呢,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="">

  

最新文章

  1. a标签绝对定位,点击区域被图片遮挡(IE下)
  2. Linux面试知识点总结
  3. Thinkphp 1.验证规则 2.静态定义 3.动态验证
  4. ubuntu启动tomcat出错解决方案
  5. B-Tree 学习
  6. C#委拖小例子
  7. Windows编程基础
  8. 手动书写小代码-foreach实现机制
  9. 【BZOJ】【1013】【JSOI2008】球形空间产生器sphere
  10. android学习笔记之ImageView的scaleType属性
  11. cocos2d-x使用DragonBones动画
  12. add-apt-repository cloud-archive:liberty
  13. MVC jsonModelBuilder
  14. 基于AngularJS的过滤与排序【转载】
  15. 我搞zabbix的那两天
  16. hive 时间函数
  17. [Swift]LeetCode551. 学生出勤纪录 I | Student Attendance Record I
  18. Druid、BoneCP、DBCP、C3P0等主流数据库对比
  19. SkylineGlobe 7.0版本 矢量数据查询示例代码
  20. Nginx PHP支持

热门文章

  1. POJ 2665 模拟,,
  2. Chosen:Select 选择框的华丽变身
  3. 微信小程序 | 小程序的转发问题
  4. 彻底解决降级安装失败无法彻底卸载应用bug
  5. 请问具体到PHP的代码层面,改善高并发的措施有哪些
  6. node.js流复制文件
  7. 从DataTable高效率导出数据到Excel
  8. C/C++中的函数指针
  9. RocketMQ学习笔记(10)----RocketMQ的Producer 事务消息使用
  10. idea编写Swing程序中文乱码的解决办法