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

User Control vs. Custom Control

·         A user control inherits System.Web.UI.UserControl class with class hierarchy (bottom up) MyUserControlà UserControlà TemplateControlà Controlà Object. Whereas a custom controls inherits System.Web.UI.Control or System.Web.UI.WebControls.WebControl class with class hierarchy (bottom up) either MyCustomControlà Controlà Object OR MyCustomControlà WebControlà Controlà Object.

·         A user control has extension .ascx and is JIT compiled, while a custom control is in the form of dynamic linked library (.ddl), thus pre-compiled.

·         A user control must encapsulate functionality of other web server control(s) through dragging and dropping in design mode. A custom control does not have any design editor. It may or may not inherit functionality of other standard control(s). It can be an entirely new one.

·         A user control is easy to create because it can be designed like a page is designed i.e. they have design editor and code behind simultaneously while a custom control does not have design editor so is harder to create. 

·         A user control requires registration and instantiation per page and resides on a page as an object and is compiled along with the page. It is not in pre-compiled form whereas a custom control (newly created or extended) is a separate and pre-compiled component.

·         A user control cannot be registered with Global Assembly Cache (GAC) while a custom control can be registered with GAC, thus giving an advantage of being a framework wide component. A custom control is more reusable because you do not need a separate copy of it for each application; it can automatically be loaded be from the GAC.

·         A user control is compiled as a part of the same page class while a custom control is compiled as a separate, distinct class. Moreover, any client side logic (html, JavaScript, DOM etc.) is also written programmatically in case of Custom controls.

·         A user control cannot provide the level of richness that a custom control can provide. It is because custom control’s class is not bound with any design. Here you can take the leverage of the flexibility and richness of .NET programming model; you can expose properties, override functions of the base class and also register complex client side logic in the class.

·         A user control may fulfill your need if you are working on a single web application while a custom control is the best choice especially when you want to make your controls redistributable, more reusable and make it a Visual Studio IDE aware component.

·         A user control can use a custom control, but vice versa is not possible.


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-12-04 5:51:40 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search