HtmlForm Class
Provides programmatic access to the HTML <form> element on the server.
Assembly: System.Web (in System.Web.dll)
The HtmlForm control is a container for server controls on a Web Forms page. All server controls that post back to the server must be placed between the opening and closing tags of an HtmlForm control.
Note: |
|---|
ASP.NET allows only a single HtmlForm control to be active on a Web Forms page. If there is more than one active HtmlForm control on a Web Forms page, the common language runtime will throw an System.Web::HttpException exception when you request the page. You can, however, use a MultiView control where each View object contains one HtmlForm control, because only one View is active at any given time. |
You can control the behavior of the HtmlForm control by setting its properties. To specify the encoding type for the form's data, set the Enctype property. The method (GET or POST) that a browser uses to post form data to the server for processing is specified by setting the Method property.
Caution: |
|---|
By default, the Method property is set to POST. You can modify the value of this property to GET, but this might break the built-in state and postback services provided by the ASP.NET page framework. |
You can configure controls that implement the IButtonControl interface to post to a different target page. This is referred to as cross-page posting. For more information, see Cross-Page Posting in ASP.NET Web Pages.
For a list of initial property values for an instance of HtmlForm, see the HtmlForm constructor.
| Topic | Location |
|---|---|
| How to: Add HTML Server Controls to a Web Page Using ASP.NET Syntax | Building ASP .NET Web Applications |
| How to: Locate the Web Forms Controls on a Page by Walking the Controls Collection | Building ASP .NET Web Applications |
| How to: Set HTML Server Control Properties Programmatically | Building ASP .NET Web Applications |
| How to: Add HTML Server Controls to a Web Page Using ASP.NET Syntax | Building ASP .NET Web Applications |
| How to: Locate the Web Forms Controls on a Page by Walking the Controls Collection | Building ASP .NET Web Applications |
| How to: Set HTML Server Control Properties Programmatically | Building ASP .NET Web Applications |
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: Minimal.
System.Web.UI::Control
System.Web.UI.HtmlControls::HtmlControl
System.Web.UI.HtmlControls::HtmlContainerControl
System.Web.UI.HtmlControls::HtmlForm
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note:
Caution: