PersistChildrenAttribute Class
Defines an attribute that is used by ASP.NET server controls to indicate at design time whether nested content that is contained within a server control corresponds to controls or to properties of the server control. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
The PersistChildrenAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | PersistChildrenAttribute(Boolean) | Initializes a new instance of the PersistChildrenAttribute class using a Boolean value indicating whether to persist nested content as nested controls. |
![]() | PersistChildrenAttribute(Boolean, Boolean) | Initializes a new instance of the PersistChildrenAttribute class using two Boolean values. One indicating whether to persist nested content as nested controls and the other indicating whether to use a custom persistence method. |
| Name | Description | |
|---|---|---|
![]() | Persist | Gets a value that indicates whether the nested content is persisted as nested controls at design time. |
![]() | TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.) |
![]() | UsesCustomPersistence | Gets a value indicating whether the server control provides custom persistence of nested controls at design time. |
| 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 PersistChildrenAttribute class. (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 PersistChildrenAttribute class is the default value of the derived clss. (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 | Indicates the default attribute state. The Default field is read-only. |
![]() ![]() | No | Indicates that nested content should not persist as nested controls at design time. This field is read-only. |
![]() ![]() | Yes | Indicates that nested content should persist as controls at design time. The Yes field is read-only. |
| 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 PersistChildrenAttribute is used in combination with the ParseChildrenAttribute to determine how nested content of a control is interpreted. If PersistChildrenAttribute is true and ParseChildrenAttribute is false, the nested content contained within an ASP.NET server control is persisted as controls. If PersistChildrenAttribute is false and ParseChildrenAttribute is true, the nested content is persisted as properties of the server control. For more 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 the metadata of a custom control so that at design time, its nested content is persisted as properties of the control. The second code example demonstrates how to use classes in an ASP.NET page.
The following code example demonstrates how to apply the PersistChildrenAttribute attribute so that none of a custom server control's nested controls are persisted as nested controls. The custom server control named CollectionPropertyControl has the PersistChildrenAttribute attribute set to false so that the Employee objects that are added are persisted as nested elements.
The following code example demonstrates how to use the CollectionPropertyControl and Employee classes in an ASP.NET page.
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.






