Whats the diffrence between Custom Control and a User Control?

Questions by sundarr

Showing Answers 1 - 4 of 4 Answers

Nilay

  • Jul 26th, 2006
 

If none of the existing ASP.NET server controls meet the specific requirements of your applications, you can create either a Web user control or a Web custom control that encapsulates the functionality you need. The main difference between the two controls lies in ease of creation vs. ease of use at design time.

Web user controls are easy to make, but they can be less convenient to use in advanced scenarios. You develop Web user controls almost exactly the same way that you develop Web Forms pages. Like Web Forms, user controls can be created in the visual designer, they can be written with code separated from the HTML, and they can handle execution events. However, because Web user controls are compiled dynamically at run time they cannot be added to the Toolbox, and they are represented by a simple placeholder glyph when added to a page. This makes Web user controls harder to use if you are accustomed to full Visual Studio .NET design-time support, including the Properties window and Design view previews. Also, the only way to share the user control between applications is to put a separate copy in each application, which takes more maintenance if you make changes to the control.

Web custom controls are compiled code, which makes them easier to use but more difficult to create; Web custom controls must be authored in code. Once you have created the control, however, you can add it to the Toolbox and display it in a visual designer with full Properties window support and all the other design-time features of ASP.NET server controls. In addition, you can install a single copy of the Web custom control in the global assembly cache and share it between applications, which makes maintenance easier.

  Was this answer useful?  Yes

yv_harish

  • Feb 19th, 2007
 

This is as simple as follows:

Both are used for Reusability.

Custom controls can be reused in any  project or application by adding the control to the toolbox or storing as com component.

User controls are used for that particular project.

karunakk

  • Jun 2nd, 2008
 

Web user controls :- Web User Control is Easier to create and another thing is that its support is limited for users who use a visual design tool one gud thing is that its contains static layout one more thing a seprate copy is required for each application.
Web custom controls:-Web Custom Control is typical to create and gud for dynamic layout and another thing is it have full tool support for user and a single copy of control is required because it is placed in Global Assembly cache.

  Was this answer useful?  Yes

User Control : A usercontrol is a templete control that provides extra behaviour to all individual control to be added to user control in GUI designer. These controls are added to the user's control Templete file .ascx. it is similar to aspx file and have codebehind  page . to enable reuse the .ascx and code behind files must be include in each project that requiers user control

Custom Web Control : Inherits from webcontrol, where you either write all code to render control or inherit from existing erbcontrol(eg Textbox ) , The class file can be compiled into .dll and can shared in globally if included in GAC(Global Assembly Cache).

Thanks

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions