Freigeben über


ControlBuilder.GetChildControlType-Methode

Ruft den Type des Steuerelementtyps ab, der einem untergeordneten Tag entspricht. Diese Methode wird vom ASP.NET-Seitenframework aufgerufen.

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

Syntax

'Declaration
Public Overridable Function GetChildControlType ( _
    tagName As String, _
    attribs As IDictionary _
) As Type
'Usage
Dim instance As ControlBuilder
Dim tagName As String
Dim attribs As IDictionary
Dim returnValue As Type

returnValue = instance.GetChildControlType(tagName, attribs)
public virtual Type GetChildControlType (
    string tagName,
    IDictionary attribs
)
public:
virtual Type^ GetChildControlType (
    String^ tagName, 
    IDictionary^ attribs
)
public Type GetChildControlType (
    String tagName, 
    IDictionary attribs
)
public function GetChildControlType (
    tagName : String, 
    attribs : IDictionary
) : Type

Parameter

  • tagName
    Der Tagname des untergeordneten Elements.
  • attribs
    Ein Array von Attributen im untergeordneten Steuerelement.

Rückgabewert

Der Type für das angegebene untergeordnete Element des Steuerelements.

Hinweise

Diese Methode wird vom ASP.NET-Seitenframework während der Analyse aufgerufen und ist nicht für den direkten Aufruf im Code gedacht.

Beispiel

' 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 NotInheritable Class MyItemControlBuilder
  Inherits ControlBuilder
  
  ' Override the GetChildControlType method to detect
  ' child elements named myitem.
  Public Overrides Function GetChildControlType(ByVal tagName As String, ByVal attribs As IDictionary) As Type
     If [String].Compare(tagName, "myitem", True) = 0 Then
        Return GetType(TextBox)
     End If
     Return Nothing
  End Function 'GetChildControlType
  
  
  ' Override the AppendLiteralString method so that literal
  ' text between rows of controls are ignored.  
  Public Overrides Sub AppendLiteralString(s As String)
  End Sub 'AppendLiteralString
End Class 'MyItemControlBuilder ' Ignores literals between rows.
// 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.
   }
}
// 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.

public class MyItemControlBuilder extends ControlBuilder
{
    // Override the GetChildControlType method to detect
    // child elements named myitem.
    public Type GetChildControlType(String tagName, IDictionary attributes)
    {
        if (String.Compare(tagName, "myitem", true) == 0) {
            return TextBox.class.ToType();
        }
        return null;
    } //GetChildControlType

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

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ControlBuilder-Klasse
ControlBuilder-Member
System.Web.UI-Namespace