Benefits of ASP.NET Controls
ASP.NET has solved the "spaghetti-code" problem described above with server controls. Server controls are tags that are understood by the server. 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 validation
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 is 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.
Why use ASP.NET controls at all? Using these controls provides four important benefits:
ASP.NET controls expose the HTML elements of a page in an intuitive object model.
ASP.NET controls automatically retain the value of their properties by participating in view state.
ASP.NET controls enable you to cleanly separate the design content of a page from the application logic.
ASP.NET controls enable you to maintain browser compatibility while still supporting advanced browser features such as JavaScript.
Comments on "Benefits of ASP.NET Controls"