次の方法で共有


HtmlForm コンストラクタ

HtmlForm クラスの新しいインスタンスを初期化します。

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

構文

'宣言
Public Sub New
'使用
Dim instance As New HtmlForm
public HtmlForm ()
public:
HtmlForm ()
public HtmlForm ()
public function HtmlForm ()
適用できません。

解説

このコンストラクタを使用して、HtmlForm クラスの新しいインスタンスを作成し、初期化します。

HtmlForm のインスタンスの初期プロパティ値を次の表に示します。

プロパティ

初期値

TagName

"form" リテラル文字列。

使用例

HtmlForm コントロールの新しいインスタンスを作成して Web ページに配置する方法を次のコード例に示します。

<%@ Page Language="VB" AutoEventWireup="True" %>

<!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 HtmlForm control.
    Dim form As HtmlForm = New HtmlForm()
    form.ID = "ButtonForm"

    ' Create an HtmlButton control.
    Dim button As HtmlButton = New HtmlButton()
    button.InnerHtml = "Click Me"

    ' Register the event-handling method for the ServerClick event of the 
    ' HtmlButton control.
    AddHandler button.ServerClick, AddressOf Button_Click

    ' Add the HtmlButton control to the HtmlForm control.
    form.Controls.Add(button)

    ' Add the HtmlForm to the control collection of the page.
    Page.Controls.Add(form)
            
  End Sub

  Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)
        
    ' Write a message to the user.
    Message.InnerHtml = "Hello World"

  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

  <title>HtmlForm Constructor Example</title>

</head>
  
<body>
  
   <h3> HtmlForm Constructor Example </h3>

   <span id="Message" runat="server"/> 

</body>

</html>
 
<%@ Page Language="C#" AutoEventWireup="True" %>

<!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 HtmlForm control.
    HtmlForm form = new HtmlForm();
    form.ID = "ButtonForm";

    // Create an HtmlButton control.
    HtmlButton button = new HtmlButton();
    button.InnerHtml = "Click Me";

    // Register the event-handling method for the ServerClick event of the 
    // HtmlButton control.
    button.ServerClick += new System.EventHandler(this.Button_Click);

    // Add the HtmlButton control to the HtmlForm control.
    form.Controls.Add(button);

    // Add the HtmlForm control to the control collection of the page.
    Page.Controls.Add(form);

  }

  void Button_Click(Object sender, EventArgs e)
  {

    // Write a message to the user.
    Message.InnerHtml = "Hello World";

  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head>

   <title>HtmlForm Constructor Example</title>

</head>

<body>
  
   <h3> HtmlForm Constructor Example </h3>

   <span id="Message" runat="server"/> 

</body>

</html>
 

プラットフォーム

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

参照

関連項目

HtmlForm クラス
HtmlForm メンバ
System.Web.UI.HtmlControls 名前空間
HtmlControl.TagName プロパティ

その他の技術情報

HTML サーバー コントロール