如何从使用它的页面获取用户控件的客户端ID? [英] How to get User control's Client ID from the Page where it was used ?
本文介绍了如何从使用它的页面获取用户控件的客户端ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
我有一个控件数量的用户控件。
我在页面中使用了这个用户控件。
实际上我想点击页面中的按钮后验证用户控件的控件。
我如何获得用户控件's control的clientId?
提前谢谢。!
Hi Friends,
I am having an user control with number of Controls.
I used this user control in a page.
Actually I want to validate the user control''s control after my button in the page is clicked.
How will i get the clientId of the user control''s control ?
Thanks in advance.!
推荐答案
控制。 ClientID [ ^ ]提供对html ID标记/元素属性的访问。
您可以使用document.getElementById访问元素,或使用jQuery绑定到submit事件:将事件处理程序绑定到提交JavaScript事件 [ ^ ]
最好的问候
Espen Harlinn
Control.ClientID[^] provides access to the html ID tag/element attribute.
You can access the element using document.getElementById, or by binding to the submit event using jQuery: Bind an event handler to the "submit" JavaScript event[^]
Best regards
Espen Harlinn
简单的写代码像这样
its simple write code like this
var control = document.getElementById('UserControlName.ControlName');
// Example
var userControl = document.getElementById('userControl1_txt1');
这里userControl1是我的Usercontrol而txt1是我在usercontrol中的文本框控件,它会给你一个对象。
试试这个。
here userControl1 is my Usercontrol and txt1 is my textbox control located in usercontrol, it''ll return you an object.
Try this.
这篇关于如何从使用它的页面获取用户控件的客户端ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文