·
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.