本文介绍了如何在设计时获取CompositeControl的标签元素子控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在设计基于CompositeControl的ASP.NET v3.5自定义控件.
但是,我不想通过代码创建我的子控件,而希望通过ASPX页面中CompositeControl中的嵌入式HTML标签元素来创建它们,例如:
I am designing an ASP.NET v3.5 custom control based on CompositeControl.
However, I do NOT want to create my child controls via code, but rather as embedded HTML tag elements within the CompositeControl in the ASPX page, such as:
<cc:MyCompositeControl ID="MyControl">
<asp:Label>Cat</asp:Label>
<asp:Label>Cat</asp:Label>
</cc:MyCompositeControl>
在运行时,MyControl.Controls包含了两个标签.
在设计时,MyControl.Controls为空.
出于各种原因,我在设计时需要此信息.
我在做什么错?
At run time, MyControl.Controls contains the two labels as expected.
At design time, MyControl.Controls is empty.
I need this information at design time for various reasons.
What am I doing wrong?
推荐答案
这篇关于如何在设计时获取CompositeControl的标签元素子控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!