Export (0) Print
Expand All

ControlBuilder.GetChildControlType Method

Obtains the Type of the control type corresponding to a child tag. This method is called by the ASP.NET page framework.

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

public virtual Type GetChildControlType(
	string tagName,
	IDictionary attribs
)

Parameters

tagName
Type: System.String

The tag name of the child.

attribs
Type: System.Collections.IDictionary

An array of attributes contained in the child control.

Return Value

Type: System.Type
The Type of the specified control's child.

This method is called by the ASP.NET page framework during parsing and is not intended to be called directly in you code.

// Create a custom ControlBuilder that interprets nested elements 
// named myitem as TextBoxes. If this class is called in a  
// ControlBuilderAttribute applied to a custom control, when 
// that control is created in a page and it contains child elements 
// that are named myitem, the child elements will be rendered as  
// TextBox server controls. This control builder also ignores literal 
// strings between elements when it is associated with a control.
[AspNetHostingPermission(SecurityAction.Demand, 
   Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class MyItemControlBuilder : ControlBuilder 
{
   // Override the GetChildControlType method to detect 
   // child elements named myitem. 
   public override Type GetChildControlType(String tagName,
                                     IDictionary attributes)
   {
      if (String.Compare(tagName, "myitem", true) == 0) 
      {
         return typeof(TextBox);
      }
      return null;
   }

   // Override the AppendLiteralString method so that literal 
   // text between rows of controls are ignored.   
   public override void AppendLiteralString(string s) 
   {
     // Ignores literals between rows.
   }
}

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft