次の方法で共有


ControlBuilder.GetChildControlType メソッド

子タグに対応するコントロールの型を示す Type を取得します。このメソッドは ASP.NET ページ フレームワークによって呼び出されます。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public Overridable Function GetChildControlType ( _
    tagName As String, _
    attribs As IDictionary _
) As Type
'使用
Dim instance As ControlBuilder
Dim tagName As String
Dim attribs As IDictionary
Dim returnValue As Type

returnValue = instance.GetChildControlType(tagName, attribs)
public virtual Type GetChildControlType (
    string tagName,
    IDictionary attribs
)
public:
virtual Type^ GetChildControlType (
    String^ tagName, 
    IDictionary^ attribs
)
public Type GetChildControlType (
    String tagName, 
    IDictionary attribs
)
public function GetChildControlType (
    tagName : String, 
    attribs : IDictionary
) : Type
適用できません。

パラメータ

  • tagName
    子のタグ名。
  • attribs
    子コントロールに格納されている属性の配列。

戻り値

指定したコントロールの子の Type

解説

このメソッドは、解析中に ASP.NET ページ フレームワークによって呼び出されるもので、コードから直接使用するためのものではありません。

使用例

' Create a custom ControlBuilder that interprets nested elements
' named myitem as TextBoxes. If this class is called in a 
' ControlBuilderAttribute applied to a custom control, when
' that control is created in a page and it contains child elements
' that are named myitem, the child elements will be rendered as 
' TextBox server controls. This control builder also ignores literal
' strings between elements when it is associated with a control.

<AspNetHostingPermission(SecurityAction.Demand, _
  Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class MyItemControlBuilder
  Inherits ControlBuilder
  
  ' Override the GetChildControlType method to detect
  ' child elements named myitem.
  Public Overrides Function GetChildControlType(ByVal tagName As String, ByVal attribs As IDictionary) As Type
     If [String].Compare(tagName, "myitem", True) = 0 Then
        Return GetType(TextBox)
     End If
     Return Nothing
  End Function 'GetChildControlType
  
  
  ' Override the AppendLiteralString method so that literal
  ' text between rows of controls are ignored.  
  Public Overrides Sub AppendLiteralString(s As String)
  End Sub 'AppendLiteralString
End Class 'MyItemControlBuilder ' Ignores literals between rows.
// Create a custom ControlBuilder that interprets nested elements
// named myitem as TextBoxes. If this class is called in a 
// ControlBuilderAttribute applied to a custom control, when
// that control is created in a page and it contains child elements
// that are named myitem, the child elements will be rendered as 
// TextBox server controls. This control builder also ignores literal
// strings between elements when it is associated with a control.
[AspNetHostingPermission(SecurityAction.Demand, 
   Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class MyItemControlBuilder : ControlBuilder 
{
   // Override the GetChildControlType method to detect
   // child elements named myitem.
   public override Type GetChildControlType(String tagName,
                                     IDictionary attributes)
   {
      if (String.Compare(tagName, "myitem", true) == 0) 
      {
         return typeof(TextBox);
      }
      return null;
   }

   // Override the AppendLiteralString method so that literal
   // text between rows of controls are ignored.  
   public override void AppendLiteralString(string s) 
   {
     // Ignores literals between rows.
   }
}
// Create a custom ControlBuilder that interprets nested elements
// named myitem as TextBoxes. If this class is called in a 
// ControlBuilderAttribute applied to a custom control, when
// that control is created in a page and it contains child elements
// that are named myitem, the child elements will be rendered as 
// TextBox server controls. This control builder also ignores literal
// strings between elements when it is associated with a control.

public class MyItemControlBuilder extends ControlBuilder
{
    // Override the GetChildControlType method to detect
    // child elements named myitem.
    public Type GetChildControlType(String tagName, IDictionary attributes)
    {
        if (String.Compare(tagName, "myitem", true) == 0) {
            return TextBox.class.ToType();
        }
        return null;
    } //GetChildControlType

    // Override the AppendLiteralString method so that literal
    // text between rows of controls are ignored.  
    public void AppendLiteralString(String s)
    {
        // Ignores literals between rows.
    } //AppendLiteralString
} //MyItemControlBuilder

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

ControlBuilder クラス
ControlBuilder メンバ
System.Web.UI 名前空間