Friday, January 20, 2012

What is difference between custom control and user control ?

User control

1) Reusability web page
2) We can’t add to toolbox
3) Just drag and drop from solution explorer to page (aspx)
4) U can register user control to. Aspx page by Register tag
5) A separate copy of the control is required in each application
6) Good for static layout
7) Easier to create
8)Not complied into DLL
9) Here page (user page) can be converted as control then
We can use as control in aspx
10.Compiled at runtime
11.HTML design (Visual design possible)
12.ASP.Net page model with code behind
13.Needs ASP.NET .aspx page to exist (can be used)
14.No design time interface
(Only a box representing the user control is available on an .aspx page)
15.Cannot be added to the ToolBox


Custom controls

1) Reusability of control (or extend functionalities of existing control)
2) We can add toolbox
3) Just drag and drop from toolbox
4) U can register user control to. Aspx page by Register tag
5) A single copy of the control is required in each application
6) Good for dynamics layout
7) Hard to create
8) Compiled in to dll
9).Precompiled
10).No visual design. HTML needs to be declared programmatically
11).Component model
12).can be used in .aspx pages, user controls or other custom server controls
13).Has design-time and run-time interface
14). Can be added to the ToolBox (using drag and drop)


First, a custom server control is precompiled, which gives it component-like behavior. If we designed correctly, it looks, acts and feels just like an ASP.NET built-in server control such as Text Box or label control.

A user control is compiled at run time. When the compiler finds the register directive in an .aspx page that points to a user control, it compiles the control before it inserts its content into the .aspx page.

Second main difference is that when using user controls, you hav ethe ability to create HTML in a designer. WE don’t hav ethe option with the Custom server control.

Note:

User controls are best when we create reusable user interface components for one specific application. Custom server controls are best for small and distinctive user interface options that can be used across many applications.

No comments:

Post a Comment