Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

ASP.NET web form


May 12, 2021 ASP.NET


Table of contents


ASP.NET Web Forms - HTML Forms

This section introduces you to ASP.NET the use of Web forms.

All server controls must appear in the "lt;form" tag, which must contain the runat"server" property.


ASP.NET web form

All server controls must appear in the label, which must contain the runat"server" property. T he runat-"server" property indicates that the form must be processed on the server. It also indicates that the controls contained inside it can be accessed by the server script:

<form runat="server">

...HTML + server controls

</form>

Note: The form is always submitted to its own page. I f you specify an action property, it is ignored. I f you omit the method property, it will default to the method "post". Also, if you don't specify the name and id properties, they are automatically ASP.NET by the file.

Note: A .aspx page can contain only one control, the "server"!

If you choose to view the source code on a .aspx page that contains a form that does not contain name, method, action, or id properties, you'll see ASP.NET add these properties to the form, as follows:

<form name="_ctl0" method="post" action="page.aspx" id="_ctl0">

...some code

</form>


Submit the form

Forms are usually submitted at the click of a button. ASP.NET the Button server controls in the system are as follows:

<asp:Button id="id" text="label" OnClick="sub" runat="server" />

The id property defines a unique name for the button, and the text property assigns a label to the button. The onClick event handle specifies a named sub-routine to execute.

In the following example, we .aspx button control in the file. Click the button to run a sub-routine that changes the text on the button:

Instance

Related articles

HTML form