Control.CreateChildControls メソッド
アセンブリ: System.Web (system.web.dll 内)


複合コントロールまたはテンプレート宣言されたサーバー コントロールを開発する場合は、このメソッドをオーバーライドする必要があります。CreateChildControls メソッドをオーバーライドするコントロールの場合、名前の衝突を避けるために、INamingContainer インターフェイスを実装してください。
詳細については、ASP.NET Web サーバー コントロール テンプレート、ASP.NET カスタム サーバー コントロールの開発 の各トピックを参照してください。

CreateChildControls メソッドのオーバーライドされたバージョンの例を次に示します。この実装では、複合コントロールは、HTML を表示する 2 つのリテラル コントロールに囲まれた TextBox コントロールを表示します。
' Override CreateChildControls to create the control tree. <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="Execution")> _ Protected Overrides Sub CreateChildControls() ' Add a LiteralControl to the current ControlCollection. Me.Controls.Add(New LiteralControl("<h3>Value: ")) ' Create a text box control, set the default Text property, ' and add it to the ControlCollection. Dim box As New TextBox() box.Text = "0" Me.Controls.Add(box) Me.Controls.Add(New LiteralControl("</h3>")) End Sub 'CreateChildControls
// Override CreateChildControls to create the control tree. [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="Execution")] protected override void CreateChildControls() { // Add a LiteralControl to the current ControlCollection. this.Controls.Add(new LiteralControl("<h3>Value: ")); // Create a text box control, set the default Text property, // and add it to the ControlCollection. TextBox box = new TextBox(); box.Text = "0"; this.Controls.Add(box); this.Controls.Add(new LiteralControl("</h3>")); }
// Override CreateChildControls to create the control tree. /** @attribute System.Security.Permissions.PermissionSet( System.Security.Permissions.SecurityAction.Demand, Name = "Execution") */ protected void CreateChildControls() { // Add a LiteralControl to the current ControlCollection. this.get_Controls().Add(new LiteralControl("<h3>Value: ")); // Create a text box control, set the default Text property, // and add it to the ControlCollection. TextBox box = new TextBox(); box.set_Text("0"); this.get_Controls().Add(box); this.get_Controls().Add(new LiteralControl("</h3>")); } //CreateChildControls
// Override CreateChildControls to create the control tree. protected override function CreateChildControls() { // Add a LiteralControl to the current ControlCollection. this.Controls.Add(new LiteralControl("<h3>Value: ")); // Create a text box control, set the default Text property, // and add it to the ControlCollection. var box : TextBox = new TextBox(); box.Text = "0"; this.Controls.Add(box); this.Controls.Add(new LiteralControl("</h3>")); }

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.CreateChildControls メソッドを検索する場合は、下記のリンクをクリックしてください。

- Control.CreateChildControls メソッドのページへのリンク