ParseChildrenAttribute Class
Defines a metadata attribute that you can use when developing ASP.NET server controls. Use the ParseChildrenAttribute class to indicate how the page parser should treat content nested inside a server control tag declared on a page. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
The ParseChildrenAttribute class allows you to specify parsing logic for a custom server control by marking the server control with the ParseChildrenAttribute metadata attribute.
Marking your server control with the metadata attribute ParseChildren(true) instructs the parser to interpret the elements that are contained within the server control's tags as properties. In this scenario, the ChildrenAsProperties property is true.
Marking your server control with the metadata attribute ParseChildren(true,"<Default Property>") sets the DefaultProperty property to the name of the property that is passed into the attribute.
Marking your server control with the metadata attribute ParseChildren(false), the default value, instructs the parser to interpret the elements that are contained within the server control's tags as content that will be parsed with an associated ControlBuilder that is, as controls. In this scenario, the ChildrenAsProperties property is false.
For information about using attributes, see Extending Metadata Using Attributes.
| Topic | Location |
|---|---|
| Walkthrough: Developing and Using a Custom Server Control | Authoring ASP.NET Controls |
| Walkthrough: Developing and Using a Custom Server Control | Authoring ASP.NET Controls |
The code example in this section contains two parts. The first code example demonstrates how to set properties for the ParseChildrenAttribute class. The second code example demonstrates how to use classes in an ASP.NET page.
The following code example demonstrates how to set the ParseChildrenAttribute object of a custom server control named CollectionPropertyControl. The ParseChildrenAttribute sets the ChildrenAsProperties property to true and the DefaultProperty property to the Employee class.
The following code example demonstrates how to use the CollectionPropertyControl and Employee classes in an ASP.NET page. Instances of the Employee class are added declaratively.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.