There are three kinds of server controls:
- HTML Server Controls - Traditional HTML tags
- Web Server Controls - New ASP.NET tags
- Validation Server Controls - For input validatio
ASP.NET - HTML Server Controls
HTML server controls are HTML tags understood by the server.
HTML elements in ASP.NET files are, by default, treated as text. To make
these elements programmable, add a runat="server" attribute to the HTML element.
This attribute indicates that the element should be treated as a server control.
The id attribute is added to identify the server control. The id reference can
be used to manipulate the server control at run time.
ASP.NET - Web Server Controls
Web server controls are special ASP.NET tags understood by the server.
Like HTML server controls, Web server controls are also created on the server
and they require a runat="server" attribute to work. However, Web server
controls do not necessarily map to any existing HTML elements and they may represent more complex elements.
ASP.NET - Validation Server Controls
Validation server controls are used to validate user-input. If
the user-input does not pass validation, it will display an error message to the
user.
Each validation control performs a specific type of validation (like
validating against a specific value or a range of values).
By default, page validation is performed when a Button, ImageButton, or
LinkButton control is clicked. You can prevent validation when a button control
is clicked by setting the CausesValidation property to false.
All server controls must appear within a <form> tag, and the <form> tag must
contain the runat="server" attribute.
Note: The form is always submitted to the page itself. If you specify an
action attribute, it is ignored. If you omit the method attribute, it will be
set to method="post" by default. Also, if you do not specify the name and id
attributes, they are automatically assigned by ASP.NET.
Note: An .aspx page can only contain ONE <form runat="server"> control!
The ViewState indicates the status of the page when submitted to the server. The
status is defined through a hidden field placed on each page with a <form runat="server"> control.
Maintaining the ViewState is the default setting for ASP.NET Web Forms.If you
want to NOT
maintain the ViewState, include the directive <%@ Page EnableViewState="false" %> at the top of
an .aspx page or add the attribute EnableViewState="false" to any control.