Provides programmatic access to the HTML <form
> element on the server.
The HtmlForm control <form runat=server
> creates an ASP.NET implementation of the HTML Form element.
Forms enable users to submit data to a server in a standardized format. Forms can collect data in different ways, using a variety of control elements.
Users typically fill in the required data by typing directly into input boxes, by checking options in a checkbox or radio button group, or by selecting options from a dropdown listbox. A submit button is ususally provided to collect and send the form’s data set to the server.
An HtmlForm control is required to process postback requests. All server control markup must be declared within the <form runat=server>...</form
> tags.
To be submitted with the form’s data set, each of the form controls must be assigned a name and have a valid value. Only controls with a valid name/value pair are sent to the receiving program for processing.
In addition to form controls, a form can contain other elements used for layout and rendering, such as tables, paragraphs, or lists.
The following sample illustrates using an HtmlForm control that contains a set of HtmlButton controls. The form handler demonstrates a simple way to determine which of the form’s controls have been selected, using the individual control’s ID.
NOTE: A Web Forms page can have only one server side <form
> control.
HtmlForm Control Syntax HTML FORM Element