HtmlSelectBuilder.GetChildControlType(String, IDictionary) 方法

定义

Type HtmlSelect获取控件的子控件。

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 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指定子控件。

适用于

另请参阅