Public Overridable ReadOnly Property Controls As ControlCollection
Dim instance As Control Dim value As ControlCollection value = instance.Controls
public virtual ControlCollection Controls { get; }
public: virtual property ControlCollection^ Controls { ControlCollection^ get (); }
/** @property */ public ControlCollection get_Controls ()
public function get Controls () : ControlCollection
在 ASP.NET 页上,当以声明方式在服务器控件的开始标记和结束标记之间添加控件时,ASP.NET 会自动将这些控件添加到包含服务器控件的 ControlCollection 中。任何不在服务器上处理的 HTML 标记或者文本字符串都视为 LiteralControl 对象。它们像其他服务器控件一样被添加到集合中。
Controls 属性允许编程访问任何服务器控件的 ControlCollection 类实例。您可以向集合添加控件、从集合中移除控件,或者循环访问集合中的服务器控件。
下面的示例说明如何通过服务器控件的 Controls 属性将子控件添加到服务器控件的 ControlCollection 对象中。
Controls.Add(New LiteralControl("<h3>Value: "))
Controls.Add(new LiteralControl("<h3>Value: "));
get_Controls().Add(new LiteralControl("<h3>Value: "));
pt] this.Controls.Add(new LiteralControl("<h3>Value: "));
Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。