AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=258&pId=-1
HTML and ASP.NET Server Controls
page
by Haroon Malik
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 11046/ 17

When I started studying ASP .NET one of the things that confused me a lot were the two different forms of server controls (HTML and ASP .NET) which almost seem to do the same thing, but were in different namespaces and had a few different functionalities. Now after a long a thorough study of books and reference material I have been able to grasp the main idea of the difference between both of these controls and how and when which of these two should be used.

Let's take a minor touch of the basics first of all. ASP .NET provides us with not only these two controls, in fact it has a large library of controls that is not limited and can be expanded by creating our own controls or by adding up the third party controls that are available on the internet or through the CD's. We can categorize the server controls that are provided by ASP .NET to us as follows

  1. Intrinsic Controls
    These are the HTML based controls like Textbox, Text Area, etc.
     

  2. Data-Centric Controls
    These controls are specially designed for the database connectivity and provide the binding facility, e.g. List controls.
     

  3. Rich Controls
    Controls like the Calendar and Data Grid are examples of rich controls.
     

  4. Validation Controls
    These controls are provided for usage with the intrinsic controls and provide functionality of data validation.

I will not be going into the details of these controls as the main focus of discussion for this article is not based on these controls rather it is to help you in understanding the differences that exist between the HTML Server Controls and the ASP .NET Server Controls.

The confusion that I had, and I think some of you may also have, is that why provide two type of controls that almost provide similar functionality, i.e. that both the controls are executed on the server side, both the controls are providing nearly similar events and have similar usage when creating forms or other pages. All this is true that both controls are nearly similar, but they have a vast difference that exists between them. The ASP .NET Server Controls are more rich in functionality as compared to their HTML Server Control counterparts. Let's take a look at some other differences that exist between these controls.

  1. Control Abstraction:
    A HTML Server Control has similar abstraction with its corresponding HTML tag and offers no abstraction.

    ASP .NET Server Controls have higher level of abstraction. An output of an ASP .NET server control can be the result of many HTML tags that combine together to produce that control and its events.
     

  2. Object Model:
    The HTML Server Controls follow the HTML-centric object model.

    ASP .NET Server Controls
    have an object model different from the traditional HTML and even provide a set of properties and methods that can change the outlook and behavior of the controls.
     

  3. Browser Compatibility:
    The HTML Server Controls have no mechanism of identifying the capabilities of the client browser accessing the current page.

    ASP .NET Server Controls can however detect the target browser's capabilities and render themselves accordingly.

Despite the differences you can still use these controls together by mixing them in an ASPX form or page. These controls can also be used together in the build up of user controls that you can design according your requirements and needs. As far as the question which control to use when? is concerned, I would say that its up to you to decide that what you are comfortable with and what you can handle easily. If you want to convert your existing HTML based template pages to ASPX based pages then it would be better for you to convert the tagged HTML controls within them to HTML Server Controls as this would only require you to add the runat="server" attribute to them. If preparing new ASPX based template pages that you want to easily target browsers according to their capabilities, e.g. a page that can have the same view on a mobile phone as it has on the Internet Explorer, would require you to use the ASP .NET Server Controls.


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 10:51:52 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search