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



HtmlForm コントロールの新しいインスタンスを作成して Web ページに配置する方法を次のコード例に示します。
<%@ Page Language="VB" AutoEventWireup="True" %> <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> <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" %> <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> <head> <title>HtmlForm Constructor Example</title> </head> <body> <h3> HtmlForm Constructor Example </h3> <span id=Message runat="server"/> </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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- HtmlForm コンストラクタのページへのリンク