HtmlSelectBuilder.GetChildControlType(String, IDictionary) 方法

定义

获取 HtmlSelect 控件的子控件的 TypeObtains the Type for the HtmlSelect control's child controls.

public:
 override Type ^ GetChildControlType(System::String ^ tagName, System::Collections::IDictionary ^ attribs);
public override Type GetChildControlType (string tagName, System.Collections.IDictionary attribs);
override this.GetChildControlType : string * System.Collections.IDictionary -> Type
Public Overrides Function GetChildControlType (tagName As String, attribs As IDictionary) As Type

参数

tagName
String

子控件的标记名称。The tag name of the child control.

attribs
IDictionary

包含在子控件中的属性的数组。An array of attributes contained in the child control.

返回

Type

Type 控件的指定子控件的 HtmlSelectThe Type of the HtmlSelect control's specified child control.

示例

下面的代码示例演示如何重写 GetChildControlType 方法以检查自定义子控件类型。The following code example demonstrates how to override the GetChildControlType method to check for custom child control types. 有关完整的工作代码示例,请参阅 HtmlSelectBuilder 类概述主题。For a complete, working code example, see the HtmlSelectBuilder class overview topic.

[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public override Type GetChildControlType(string tagName, IDictionary attribs)
{
    // Distinguish between two possible types of child controls.
    if (tagName.ToLower().EndsWith("myoption1"))
    {
        return typeof(MyOption1);
    }
    else if (tagName.ToLower().EndsWith("myoption2"))
    {
        return typeof(MyOption2);
    }
    return null;
}
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Overrides Function GetChildControlType(ByVal tagName As String, ByVal attribs As IDictionary) As Type

    ' Distinguish between two possible types of child controls.
    If tagName.ToLower().EndsWith("myoption1") Then
        Return GetType(MyOption1)
    ElseIf tagName.ToLower().EndsWith("myoption2") Then
        Return GetType(MyOption2)
    End If
    Return Nothing

End Function 

注解

使用 GetChildControlType 方法返回 Type 控件中指定子控件的 HtmlSelectUse the GetChildControlType method to return the Type of a specified child control in an HtmlSelect control.

适用于

另请参阅