ASP.NET Web Form
- Previous page WebForms Gebeurtenissen
- Next page WebForms ViewState
Alle server-knoppen moeten zich bevinden binnen de <form>-tag, en de <form>-tag moet de eigenschap runat="server" bevatten.
ASP.NET Web Formulier
Alle server-knoppen moeten zich bevinden binnen de <form>-tag, en de <form>-tag moet de eigenschap runat="server" bevatten. De eigenschap runat="server" geeft aan dat het formulier op de server moet worden verwerkt. Het geeft ook aan of de ingesloten knoppen toegankelijk zijn voor serverscripts:
<form runat="server">...HTML + server controls</form>
Note:The form is always submitted to the same page. If you specify an action attribute, it will be ignored. If you omit the method attribute, it will be set to method="post" by default. At the same time, if you do not specify the name and id attributes, they will be automatically assigned by ASP.NET.
Note:A .aspx can only contain one <form runat="server"> control!
If you view the source code of a .aspx page and the form does not have the name, method, action, or id attributes, you will see that ASP.NET has added these attributes to the form. Similar to this:
<form name="_ctl0" method="post" action="page.aspx" id="_ctl0">...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:
<asp:Button id="id" text="label" OnClick="sub" runat="server" />
The id attribute defines a unique name for the button, while the text attribute assigns a label to the button. The onClick event handler specifies a subroutine to be executed.
In the following example, we declare a button control in a .aspx file. One mouse click can run a subroutine and change the text on the button.
- Previous page WebForms Gebeurtenissen
- Next page WebForms ViewState