无法访问控件 [英] control is not accessible

查看:96
本文介绍了无法访问控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我正在尝试访问由Ajax调用动态创建的按钮单击控件,并使用document.ready事件在浏览器上呈现.

我无法在button_click事件中访问它.

实际上,我是通过.aspx页面上的Jquery响应返回整个下面的代码的

Hi frds,

I am trying access a control on button click that is dynamically created by Ajax call, and rendering on browser with document.ready event.

I am not able to access it on button_click event.

Actually i am returning whole below code through Jquery response on .aspx page

<ul><li><input id="chk1" type="checkbox" name="chk1"></li></ul>



然后像这样



and rendring it like that

$(".Columns").html(obj.d);</pre>



但是在.cs文件中,我无法访问"chk1",请提出建议.



but in .cs file i am not able to access "chk1", please suggest.

Thanks in advanced.

推荐答案

(.Columns").html(obj.d);</pre>
(".Columns").html(obj.d);</pre>



但是在.cs文件中,我无法访问"chk1",请提出建议.

谢谢.



but in .cs file i am not able to access "chk1", please suggest.

Thanks in advanced.


如果您如上所述使用AJAX返回按钮的HTML,那么您将无法在服务器端访问该按钮.

这只是从服务器传输到浏览器的HTML,而不是在页面加载事件或回发事件中呈现的常规控件.

顺便说一下,您需要在代码中分离关注点.

为什么在客户端需要一半的处理登录,而在服务器端却需要其余的登录?
If you using AJAX to return the HTML of the button like you mentioned above ,then you''ll not be able to access the same in the server side.

It is just the HTML transferred from Server to Browser and not a normal control which was rendered on the Page load event or post back event.

By the way you need to have separation of concerns in your code.

Why you need half of the processing login in client side and remaining in the server side?


hi ...

您应该为控件设置属性 runat ="server" ...
hi...

you should set the property runat="server" for your control...


这篇关于无法访问控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆