This documentation is archived and is not being maintained.
HtmlForm Constructor
.NET Framework 1.1
Initializes a new instance of the HtmlForm class.
[Visual Basic] Public Sub New() [C#] public HtmlForm(); [C++] public: HtmlForm(); [JScript] public function HtmlForm();
Remarks
Use this constructor to create and initialize a new instance of the HtmlForm class.
The following table shows the initial property value for an instance of HtmlForm.
| Property | Initial Value |
|---|---|
| TagName | The "form" literal string. |
Example
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <script runat="server" > Sub Page_Load(sender As Object, e As EventArgs) ' Create a new HtmlForm. 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. form.Controls.Add(button) ' Add the HtmlForm to the Controls collection of the Page. Page.Controls.Add(form) End Sub Sub Button_Click(sender As Object, e As EventArgs) Message.InnerHtml = "Hello World" End Sub </script> <body> <h3> HtmlForm Constructor Example </h3> <span id=Message runat="server"/> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <script runat="server" > void Page_Load(Object sender, EventArgs e) { // Create a new HtmlForm. 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. form.Controls.Add(button); // Add the HtmlForm to the Controls collection of the Page. Page.Controls.Add(form); } void Button_Click(Object sender, EventArgs e) { Message.InnerHtml = "Hello World"; } </script> <body> <h3> HtmlForm Constructor Example </h3> <span id=Message runat="server"/> </body> </html>
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlForm Class | HtmlForm Members | System.Web.UI.HtmlControls Namespace | TagName
Show: