Developing Custom Controls - Part 1
page 3 of 8
by G. Mohyuddin
Feedback
Average Rating: 
Views (Total / Last 10 Days): 38660/ 52

Types of Custom Controls

Literally speaking, "a control is custom for user if it fulfills a requirement that can’t be satiated by any standard control." The term custom control becomes vague sometime for the user when there is a parallel term of user controls which are also custom controls in nature, but are created differently. I would like to put light on this ambiguity and will try to resolve it. Yet before this, it is more important to know the types of custom controls and their place in the hierarchy of controls.

It is important to know that all controls are server controls i.e. they run at server and are rendered into the appropriate HTML controls at the client's browser.

We can make two major level categories of server controls.

·         Just In Time (JIT) Compiled

·         Pre Compiled 

JIT compiled controls are those controls that are embeddable in the source of aspx page and are compiled as per demand i.e. just in time. These controls, directly or indirectly, are inherited from System.Web.UI.WebControls.WebControl or System.Web.UI.Control which let them expose properties and provide events. They are compiled when the page gets compiled by the Framework. The following are the main types of JIT compiled controls.

·         HTML server controls

·         Web server controls

·         Validation controls

·         User controls

Let us take a look on these controls one by one.

HTML Server Controls

HTML controls support an additional property of “runat.” If this set is to “server,” it runs at server and is accessible in the code behind. Therefore, it is said to be an HTML Server control. Since these controls require less UI support, they are inherited from System.Web.UI.Control.

Web Server Controls

Web server controls are all standard server side controls that are shipped with ASP.NET. They include simple controls such as Panel and as rich as GridView. The basic purpose of these controls is to minimize the effort required for designing pages or building tools/controls that automatically generate user interface. These controls hide details of their internal working and make the task easier and less erroneous for developers. It is important to know that these controls inherit one of these two classes.

System.Web.UI.Control

It defines the properties, methods, and events that are common to all web server controls, for example methods and events needed handle the execution lifecycle. This does not support any UI specific feature. The controls that require no UI support inherit this class, such as ASP.NET controls including Literal, Repeater, PlaceHolder and XML.

or

System.Web.UI.WebControls.WebControl

The WebControl class inherits Control class and exposes additional properties and provides methods for UI support. A control that renders some UI should be inherited from WebControl. It is the class which provides UI-related properties such as BackColor, ForeColor, Font, Height, Width, etc. All ASP.NET controls except aforementioned controls inherit this class.

Validation Controls

These controls are used for validation of the input of other controls of a page/user control. These controls can perform client side, server side or both types of validation. Validation controls inherits the BaseValidator class that implements IValidator interface and inherits Label class, thus they inherit System.Web.UI.WebControls.WebControl indirectly.

User Controls

Lastly let us have a look at user controls and know how they are different from custom controls. User controls are custom in nature by purpose not by architecture. Development and design-wise they have nothing common with custom controls. They are closer to an aspx page than a custom control. This may be a bit misleading yet we have to take them entirely separate. Their architecture and way of working is entirely different the only thing that is common is they both can fulfill custom needs of a user.

The following are the important differences between a user control and a custom control from all aspects.


View Entire Article

User Comments

Title: Comparing UC vs CC is awesome   
Name: satya
Date: 2010-03-22 11:16:17 PM
Comment:
Differences b/w User controls, Custom controls are explained excellently.
Title: Error Rendering Control   
Name: Luiz Ricardo
Date: 2009-03-27 9:17:41 AM
Comment:
I have "Error rendering control" when I change TextCaseMode or any other enum property at design time.
Did I forget anything?
Title: Good   
Name: Raju
Date: 2009-03-23 6:29:02 AM
Comment:
At design time,if I change the property it will show
error rendering control
Title: Looks promising   
Name: JP
Date: 2008-12-10 5:56:38 AM
Comment:
reusable in true sense!
Title: Testing   
Name: Tester
Date: 2008-12-10 5:40:56 AM
Comment:
Really good
Title: Good show !   
Name: Ananth
Date: 2008-06-09 3:56:36 PM
Comment:
Nice and Neat !!
Title: Really Intresting   
Name: Uzair Aziz
Date: 2008-03-14 8:58:48 AM
Comment:
It is really helpful and easy to understand for me.now i can develop other custom controls.

Tnank you so much.....
Title: thanks   
Name: ngocthom
Date: 2008-01-09 10:58:04 PM
Comment:
thanks so much for your supply, it is very useful






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-02-26 10:20:53 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search