共用方式為


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

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

適用於

另請參閱