如何从用户控件中找到控件ID [英] How to find control id from user control
问题描述
我有一个Web用户控件,其中包含"AssociatedLableId"属性和标签.
I have a web user control which contains ''AssociatedLableId'' property and a label.
<uc1:UC id="uc1" run="Ser" AssociatedLableId="lblLable" />
并在aspx页面和已注册的用户控件中添加了一个Label和一个按钮.
现在,当我单击按钮时,aspx页面的标签控件文本将分配给使用JS的Web用户控件的标签控件.
我尝试关注但不正确.
and added a Label and a button in aspx page and registered User Control .
Now when I click the button then the text of label control of aspx page assigned to label control of web user control using JS.
I tried following but not right.
<asp:button id ="btn" run="Ser" text="Click" onClientClick="return assignValue();" />
function assignValue()
{
document.getElementById('UserControlsAssocitedControlId').value = document.getElementById('aspxPageLableId').value;
}
AssociatedLableId
属性用于获取aspx页的Label控件的ID.
我可以找到UserControlsAssocitedControlId
的ID,但是如何找到我在JS的AssociatedLableId
属性中分配的aspxPageLableId
.
AssociatedLableId
property is used to get the Id of aspx page''s Label control.
I can find the Id of UserControlsAssocitedControlId
but how can I find the aspxPageLableId
which I assigned in the AssociatedLableId
property in JS.
推荐答案
此链接,
http://stackoverflow.com/Questions/438556/how-to-access-asp-control-located-in-a-user-control-via-javascript [
Hi, Check this link,
http://stackoverflow.com/questions/438556/how-to-access-asp-control-located-in-a-user-control-via-javascript[^]
这篇关于如何从用户控件中找到控件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!