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的用法
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="">
e.Row.Attributes.Add的更多相关文章
- 服务器控件button点击时执行脚本弹出提示对话框Button2.Attributes.Add("onclick","事件")
<HTML> <HEAD> <title>**********资料更新</title> <meta content="Microso ...
- Attributes.Add用途与用法
Attributes.Add("javascript事件","javascript语句"); 如: this.TextBox1.Attributes.add(& ...
- aspx页面,后端通过Attributes.Add给textbox添加事件时,传参失效问题。
测试一:------------------------------------------------------------------------------------------------ ...
- 当有“Button1.Attributes.Add("onclick", "return confirm('你确定要保存修改吗?')");”时,验证控件失效的解决方法
同一个页面用Js和服务器验证控件OnClientClick提交问题 实现功能: 点击Button按钮的OnClientClick事件,不会影响服务器验证控件的验证功能 ...
- 实现CheckBox的三种选中状态(全选、半选、不选)在GridView中模拟树形的功能
度娘了很多帖子,只说三种状态要用图片替换来做,但没找到有用的例子,被逼自己写了一个 三方控件肯定是很多的,如jstree,可以直接用 由于公司的UDS限制,不能上传图片,只能文字说明了. 就是要在gr ...
- GridView 树形结构分组的功能
在“会飞的鱼”博客中看到GridView实现树形结构的代码,经过修改,添加了树形结构中的复选框功能,欢迎吐槽. 源地址:http://www.cnblogs.com/chhuic/archive/20 ...
- 在GridView隐藏字段
在GridView中隐藏一字段,方便这条记录的处理,同时隐藏一个Button实现点击这条记录时的处理 1.绑定 <asp:TemplateField> ...
- GridView,Repeater增加自动序号列
有三种实现的方式, 第一种方式,直接在Aspx页面GridView模板列中.这种的缺点是到第二页分页时又重新开始了. <Columns> <asp:TemplateField Hea ...
- GridView点击行触发SelectedIndexChanged事件
1.在<% @Page ...... %>指令中添加 EnableEventValidation="false" 2.在RowDataBound事件中添加 protec ...
随机推荐
- ubuntu 14.04开机出现错误“Error found when loading /root/.profile”解决
在刚修改完root权限自动登录后,发现开机出现以下提示: Error found when loading /root/.profile stdin:is not a tty ………… 解决方法:在终 ...
- Electron 问题
打包 Mac 桌面程序时报上述错误 E:\research\node\XXX>electron-packager ./ XXX --platform=darwin --arch=x64 --ic ...
- js获取浏览器中相关容器的高度
网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: document.body.offset ...
- null和undifned的区别
null和undifned的区别 1 从类型方面:null的类型是对象,undified的类型是undified. 2 从定义方面:null是一个表示"无"的对象,转为数值时为0: ...
- 性能优化实战-join与where条件执行顺序
昨天经历了一场非常痛苦的性能调优过程,但是收获也是刻骨铭心的,感觉对sql引擎的原理有了进一步认识. 问题起源于测试人员测一个多条件检索的性能时,发现按某个条件查询会特别慢.对应的sql语句简化为: ...
- Unity 声音播放不受Time.scale为0的影响
其他会暂停,目前发现声音不受影响 嗯,就这样.
- C# 鼠标左右手切换
using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServi ...
- org.xml.sax.SAXParseException: Failed to read schema document 的原因分析与解决方法
现象: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema documen t 'http://www.s ...
- 在centos系统中增、删交换分区
Swap介绍: Linux 将物理内存分为内存段,叫做页面.交换是指内存页面被复制到预先设定好的硬盘空间(叫做交换空间)的过程,目的是释放对于页面的内存.物理内存和交换空间的总大小是可用的虚拟内存的总 ...
- Label,PushButton,ToolButton 实现动态图片按钮,Label显示gif动画
.h文件 public: explicit event(QWidget *parent = 0); ~event(); QImage image; QLabel *label; QLabel *lab ...