ASP.NET Web Forms - HTML Forms
All server controls must appear within a <form> tag, and the <form> tag must include the runat="server" attribute.
ASP.NET Web Forms
All server controls must appear within a <form> tag, and the <form> tag must include the runat="server" attribute. The runat="server" attribute indicates that the form must be processed on the server. It also indicates that the controls contained within it can be accessed by server scripts:
...HTML + server controls
</form>
Note:The form is always submitted to its own page. If you specify an action attribute, it will be ignored. If you omit the method attribute, it will default to method="post". Also, if you do not specify the name and id attributes, they will be automatically assigned by ASP.NET.
Note:An .aspx page can only contain one <form runat="server"> control!
If you choose to view the source code in an .aspx page that contains a form without the name, method, action, or id attributes, you will see that ASP.NET has added these attributes to the form, as shown below:
...some code
</form>
Submit Form
Forms are usually submitted by clicking a button. The format of the Button server control in ASP.NET is as follows:
The id attribute defines a unique name for the button, and the text attribute assigns a label to the button. The onClick event handler specifies a named subroutine to be executed.
In the following example, we declare a button control in an .aspx file. A single mouse click can run a subroutine that can change the text on the button.
Example
Other Extensions