ChildControlType Property
Collapse the table of content
Expand the table of content

ParseChildrenAttribute.ChildControlType Property


Gets a value indicating the allowed type of a control.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public Type ChildControlType { get; }

Property Value

Type: System.Type

The control type. The default is System.Web.UI.Control.

If the allowed control type is null, meaning that it has not been specified, the default type, which is a System.Web.UI.Control control, is returned.

The following code example demonstrates how to query the ChildControlType property. For definitions of the CollectionPropertyControl and Employee classes that are used in this code example, see ParseChildrenAttribute.

<%@ Page Language="C#" %>
<%@ Register TagPrefix="AspSample" Assembly="Samples.AspNet.CS.Controls" Namespace="Samples.AspNet.CS.Controls" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">

  protected void Page_Load(object sender, EventArgs e)
    // Create a new employee object and add it to the custom control.
    Employee e1 = new Employee("Employee 2", "Title 2", "Alias 2");

    // Verify attribute values.
    ParseChildrenAttribute p = 

    StringBuilder sb = new StringBuilder();
    sb.Append("The ChildControlType property is " + p.ChildControlType.ToString() + "<br />");
    sb.Append("The ChildrenAsProperties property is " + p.ChildrenAsProperties.ToString() + "<br />");
    sb.Append("The IsDefaultAttribute method returns " + p.IsDefaultAttribute().ToString());
    Message.Text = sb.ToString();


<html xmlns="" >
<head runat="server">
    <title>ParseChildrenAttribute Example</title>
    <form id="form1" runat="server">
      <asp:Label ID="Message"
      <AspSample:CollectionPropertyControl id="CollectionPropertyControl1" 
        <AspSample:Employee Name="Employee 1" 
                            Title="Title 1" 
                            Alias="Alias 1" />

.NET Framework
Available since 2.0
Return to top
© 2016 Microsoft