HtmlSelectBuilder.GetChildControlType(String, IDictionary) 方法

定义

获取 HtmlSelect 控件的子控件的 Type

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

子控件的标记名称。

attribs
IDictionary

包含在子控件中的属性的数组。

返回

Type

Type 控件的指定子控件的 HtmlSelect

示例

下面的代码示例演示如何重写 GetChildControlType 方法来检查自定义子控件类型。 有关完整的工作代码示例,请参阅 HtmlSelectBuilder 类概述主题。

[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 控件 HtmlSelect 中的指定子控件。

适用于

另请参阅