Thursday, November 20, 2008

What is custom control? What is the difference between custom control and user control?

Custom controls are controls that are developed by the developer
or a third party vendor. Custom controls are not provided along with
.NET.

Difference between Custom Controls and User Controls.

1.User Control is a page file with extension .ascx which can only be used within
a single application. But custom controls are assemblies(dll files) that can be
used in multiple applications.

2.User Controls cannot be added to the ToolBox of VS.NET . To use a user Control with in an
aspx page u have to drag the user Control from the solution Explorer to designer page.
But Custom Controls can be added to ToolBox of VS.NET.

3.User Controls can be viewed as a sort of generic controls during the design time.
The proper GUI of user controls can be viewed only during the run time.
But Custom Controls can be viewed during the design time.

4. User controls are created from existing Webserver and html server controls .
But a developer who creates custom controls have to render every thing from the scratch.

5.Since the dll assembly of a custom control is being used,a custom control developed in C# can be used in a project developed in VB.NET or any other managed code and vice versa.

User Controls:

1.Have an ascx extension.
2.Are compiled at runtime when the page is loaded.
3.Visual design is possible, just like an aspx page and uses the ASP.Net page model with code behind file.
4.Can only be used on a host aspx page or another user control.
5.Cannot be added to the ToolBox.
6.Can only be used in the current web application (source must be copied to another application to use).

Custom Server Control:

1.Exist in precompiled assemblies.
2.Code entirely contained in .cs (or .vb)
3.No visual designer. Any HTML code needs to be declared programmatically.
4.Can be used in .aspx pages, user controls or other custom server controls.
5.Can be added to the ToolBox (drag and drop)
6.Can be shared between web applications.

No comments: