HtmlGenericControl コンストラクタ ()
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、既定値で HtmlGenericControl クラスの新しいインスタンスを作成し、初期化します。サーバー側の <span> 要素を動的に作成するときによく使用されます。
HtmlGenericControl のインスタンスの初期プロパティ値を次の表に示します。

既定のコンストラクタを使用して、HtmlGenericControl クラスの新しいインスタンスを作成する方法を次のコード例に示します。
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Create a new HtmlGenericControl. Dim NewControl As New HtmlGenericControl() ' Set the properties of the new HtmlGenericControl control. NewControl.ID = "NewControl" NewControl.InnerHtml = "This is a dynamically created HTML server control." ' Add the new HtmlGenericControl to the Controls collection of the ' PlaceHolder control. ControlContainer.Controls.Add(NewControl) End Sub </script> <html > <head runat="server"> <title>HtmlGenericControl Constructor Example</title> </head> <body> <form runat="server"> <div> <h3> HtmlGenericControl Constructor Example </h3> <asp:PlaceHolder ID="ControlContainer" runat="server"/> </div> </form> </body> </html>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Create a new HtmlGenericControl. HtmlGenericControl NewControl = new HtmlGenericControl(); // Set the properties of the new HtmlGenericControl control. NewControl.ID = "NewControl"; NewControl.InnerHtml = "This is a dynamically created HTML server control."; // Add the new HtmlGenericControl to the Controls collection of the // PlaceHolder control. ControlContainer.Controls.Add(NewControl); } </script> <html > <head id="Head1" runat="server"> <title>HtmlGenericControl Constructor Example</title> </head> <body> <form runat="server"> <div> <h3> HtmlGenericControl Constructor Example </h3> <asp:PlaceHolder ID="ControlContainer" runat="server"/> </div> </form> </body> </html>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HtmlGenericControl コンストラクタ (String)
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、指定したタグで HtmlGenericControl クラスの新しいインスタンスを作成し、初期化します。これにより、.NET Framework クラスで直接表されない HTML サーバー コントロール要素を動的に作成できるようになります。
HtmlGenericControl のインスタンスの初期プロパティ値を次の表に示します。
![]() |
---|
tag パラメータが null 参照 (Visual Basic では Nothing) に設定されると、TagName プロパティは String.Empty に設定されます。 |

オーバーロードされたコンストラクタを使用して、HtmlGenericControl クラスの新しいインスタンスを作成する方法を次のコード例に示します。
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Create a new HtmlGenericControl. Dim NewControl As New HtmlGenericControl("div") ' Set the properties of the new HtmlGenericControl control. NewControl.ID = "NewControl" NewControl.InnerHtml = "This is a dynamically created HTML server control." ' Add the new HtmlGenericControl to the Controls collection of the ' PlaceHolder control. ControlContainer.Controls.Add(NewControl) End Sub </script> <html > <head runat="server"> <title>HtmlGenericControl Constructor Example</title> </head> <body> <form runat="server"> <div> <h3> HtmlGenericControl Constructor Example </h3> <asp:PlaceHolder ID="ControlContainer" runat="server"/> </div> </form> </body> </html>
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Create a new HtmlGenericControl. HtmlGenericControl NewControl = new HtmlGenericControl("div"); // Set the properties of the new HtmlGenericControl control. NewControl.ID = "NewControl"; NewControl.InnerHtml = "This is a dynamically created HTML server control."; // Add the new HtmlGenericControl to the Controls collection of the // PlaceHolder control. ControlContainer.Controls.Add(NewControl); } </script> <html > <head runat="server"> <title>HtmlGenericControl Constructor Example</title> </head> <body> <form runat="server"> <div> <h3> HtmlGenericControl Constructor Example </h3> <asp:PlaceHolder ID="ControlContainer" runat="server"/> </div> </form> </body> </html>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


HtmlGenericControl コンストラクタ

名前 | 説明 |
---|---|
HtmlGenericControl () | HtmlGenericControl クラスの新しいインスタンスを既定値で初期化します。 |
HtmlGenericControl (String) | タグを指定して、HtmlGenericControl クラスの新しいインスタンスを初期化します。 |

関連項目
HtmlGenericControl クラスHtmlGenericControl メンバ
System.Web.UI.HtmlControls 名前空間
その他の技術情報
HTML サーバー コントロール- HtmlGenericControl コンストラクタ ()のページへのリンク