Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Why to Use ASP.NET Server Controls in Place of HTML Controls?

  • Last Updated : 17 Nov, 2021

Basically HTML controls are client side controls and ASP.NET controls are server side controls.

We prefer ASP.NET controls  as our web controls. As with the HTML controls we can’t maintain the state ie the data is lost, we can say it as it does not provide state management. And while writing the code we can’t access HTML controls from code behind the files. 

So even though the execution is fast at client side we only prefer the ASP.NET because of the above two reasons. HTML controls does not even support object oriented paradigm and it has a limited set of properties and methods where as ASP.NET has full support of object oriented paradigm and it can be directly accessed from code behind the files and it has a rich set of properties and methods.

  • ASP.NET: ASP.NET is a server side framework for web development hich provides the services required to develop enterprise class web applications with minimal code. It ships within the .NET framework so it has access to all build in classes present within the .NET framework while writing ASP.NET code. It has better user authentication. It uses compiled code which in turn increases the performance of the applications. ASP.NET pages run as code on the server. The page is configured in such a way that when ever a user clicks buttons it gets submitted to the server. When the page is refreshed and submitted back to itself then it runs ts server code again and renders a new version of itself back to the users. Normally Web Forms page gets compiled on the server as page objects and they are cached in server memory. An ASP.NET page is a combination of all the server side controls in a page and code of event handling it which is written in the code file behind it, hence the page is executed as a single unit. When the user requests the page for the first time the page is dynamically compiled and it gets executed. Hence it is not required to precompile the pages into assemblies. ASP.NET server controls are controled by abstract, strongly typed object models. They can be dragged and droped on the .aspx page from the toolbox. And also we can include special controls to it such as calendar controls and validation controls.
  • NameSpace: We use the following namespace for web controls: System.Web.UI.WebControls The server controls are designed for making the develop tools and applications easier. The process of creating the web forms is now more efficient and simple. Frequently used web server controls are TextBox, Label, Button, CheckBox, RadioButton, GridView
  • Validation Controls: Validating the data is very important while getting the data entriesfrom a user end. Validation should be done at server side also in addition to the client side. Validation controls are generally placed adjacent to the controls that they are validating. Validation controls validate data at the client side before postback process. Validation Controls are placed on the web form and then they are setting its ControlToValidate property to the controls you want to validate. Validation Summary control is used to display the validation related error messages of all the controls at once ie at one place. We need to even provide a control such as button which triggers a postback event. Because although validation happens at client side , the validation process doesn’t even start until a postback is requested.
  • State Management: State Management is a mechanism which allows you to maintain state and page information over multiple requests made for the same or for different pages. Web Pages developed in ASP.NET are HTTP based and HTTP protocol is a stateless protocol. To overcome this limitation ASP.NET supports several  concepts to preserve data called state management. ASP.NET provides different alternatives for state management they are Client side, Server side. In Client side we use ViewState, Hidden fields, Cookies, Query strings. While in Server side we use Applications, Sessions, Database to store data.
My Personal Notes arrow_drop_up
Recommended Articles
Page :