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 項中。

適用於

另請參閱