给控件增加javascript方法(method)! document.all['aaaaa'].popup('cccc');这下明白了吧 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样写试试把protected override void AddAttributesToRender(HtmlTextWriter writer){ writer.AddAttribute("popup", "var func = function(value){alert(value);}");}eval($('aaaaa').popup);func('test'); var $=function(id){return document.getElementById(id);} prototype.js 应用于学习还是8错的 babyrockxray(紫色阴影) : 你这种方式不符合面向对象的。Input有一个select()方法,是把里面的文本选中,我就想给控件增加这样一种方法。 给控件不能这么加的<html><body><div id="id1"></div><script>Function.prototype.Bind=function(f){ _this=this; return function(){ return f.apply(null); }}var obj1=document.createElement("input");obj1.type="text";f1=function(){}f2=function(){alert('123');}obj1.onclick=f1.Bind(f2);document.getElementById("id1").appendChild(obj1);</script></body></html> Function.prototype.Bind=function(f){ _this=this; return function(){ return f.apply(null); }}写得有点儿不太好,不过好象这个也是prototype.js的方法,lz可以看看源码 babyrockxray(紫色阴影) : 你这种方式不符合面向对象的。Input有一个select()方法,是把里面的文本选中,我就想给控件增加这样一种方法。==========那你就不能这么加,得在js里面定义一下$('aaaaa').popup = function(value){alert(value);}$('aaaaa').popup('cccc'); 关于repeater控件遍历的问题,高手来帮帮小弟呀。 FusionChart问题 大家帮我看看这个代码哪错了?急!!!!!!!!!!!在线等! 求能在网页左右两边跟随页面一起滚动的图片(网页)的js代码 [帮帮我把~~~~~555~~~]有关于如何设置文件夹权限的问题?? 网站内容的安全问题 从类型“DBNull”到类型“String”的强制转换无效。 怎么解决????? 我的sybase连接报错为什么呢? 后台数据验证的时候前台实时显示进度? 求救﹕C#中读取xml文件的一个问题 asp.net里面为什么要用存储过程??? csdn的问题排序在客户体验上有问题
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
writer.AddAttribute("popup", "var func = function(value){alert(value);}");
}eval($('aaaaa').popup);
func('test');
return document.getElementById(id);
}
<body>
<div id="id1"></div>
<script>
Function.prototype.Bind=function(f)
{
_this=this;
return function(){
return f.apply(null);
}
}
var obj1=document.createElement("input");
obj1.type="text";
f1=function(){}
f2=function(){alert('123');}
obj1.onclick=f1.Bind(f2);
document.getElementById("id1").appendChild(obj1);</script>
</body>
</html>
{
_this=this;
return function(){
return f.apply(null);
}
}写得有点儿不太好,不过好象这个也是prototype.js的方法,lz可以看看源码
那你就不能这么加,得在js里面定义一下
$('aaaaa').popup = function(value){alert(value);}$('aaaaa').popup('cccc');