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 type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ParseChildrenAttribute() | Initializes a new instance of the ParseChildrenAttribute class. |
![]() | ParseChildrenAttribute(Boolean) | Initializes a new instance of the ParseChildrenAttribute class using the ChildrenAsProperties property to determine if the elements that are contained within a server control are parsed as properties of the server control. |
![]() | ParseChildrenAttribute(Type) | Initializes a new instance of the ParseChildrenAttribute class using the ChildControlType property to determine which elements that are contained within a server control are parsed as controls. |
![]() | ParseChildrenAttribute(Boolean, String) | Initializes a new instance of the ParseChildrenAttribute class using the childrenAsProperties and defaultProperty parameters. |
| Name | Description | |
|---|---|---|
![]() | ChildControlType | Gets a value indicating the allowed type of a control. |
![]() | ChildrenAsProperties | Gets or sets a value indicating whether to parse the elements that are contained within a server control as properties. |
![]() | DefaultProperty | Gets or sets the default property for the server control into which the elements are parsed. |
![]() | TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.) |
| Name | Description | |
|---|---|---|
![]() | Equals | Determines whether the specified object is equal to the current object. (Overrides Attribute::Equals(Object).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for the ParseChildrenAttribute object. (Overrides Attribute::GetHashCode().) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsDefaultAttribute | Returns a value indicating whether the value of the current instance of the ParseChildrenAttribute class is the default value of the derived class. (Overrides Attribute::IsDefaultAttribute().) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | Default | Defines the default value for the ParseChildrenAttribute class. This field is read-only. |
![]() ![]() | ParseAsChildren | Indicates that the nested content that is contained within the server control is parsed as controls. |
![]() ![]() | ParseAsProperties | Indicates that the nested content that is contained within a server control is parsed as properties of the control. |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames | Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo | Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount | Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke | Provides access to properties and methods exposed by an object. (Inherited from Attribute.) |
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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.






