Part.Controls 属性

定义

获取 ControlCollection 对象,该对象包含用户界面层次结构中指定服务器控件的子控件。Gets a ControlCollection object that contains the child controls for a specified server control in the user interface hierarchy.

public:
 virtual property System::Web::UI::ControlCollection ^ Controls { System::Web::UI::ControlCollection ^ get(); };
public override System.Web.UI.ControlCollection Controls { get; }
member this.Controls : System.Web.UI.ControlCollection
Public Overrides ReadOnly Property Controls As ControlCollection

属性值

指定服务器控件的子控件的集合。The collection of child controls for the specified server control.

注解

在 ASP.NET 页上,如果在服务器控件的开始标记和结束标记之间以声明方式添加控件,则 ASP.NET 会自动将控件添加到包含服务器控件的 ControlCollection 对象。On an ASP.NET page, when controls are added declaratively between the opening and closing tags of a server control, ASP.NET automatically adds the controls to the containing server control's ControlCollection object. 未在服务器上处理的任何 HTML 标记或文本字符串都将被视为 LiteralControl 的对象。Any HTML tags or text strings that are not processed on the server are treated as LiteralControl objects. 这些将添加到集合中,如其他服务器控件。These are added to the collection like other server controls.

Controls 属性允许你以编程方式访问任何服务器控件的 ControlCollection 类的实例。The Controls property allows you programmatic access to the instance of the ControlCollection class for any server control. 您可以向集合添加控件、从集合中移除控件或循环访问集合中的服务器控件。You can add controls to the collection, remove controls from the collection, or iterate through the server controls in the collection.

适用于

另请参阅