Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As stated in the question, is there any difference in the meaning of the two as applied to the Controls of .NET. Or are they alias of one another?

share|improve this question
add comment

4 Answers 4

up vote 5 down vote accepted

A user control is a composition of existing controls while a custom control is a control derived from one base control. This might be better in stackoverflow btw.

share|improve this answer
    
Thanks. I was actually caring for definition and I feel this isn't any direct Programming/Software question. –  Shamim Hafiz Aug 19 '11 at 10:12
add comment

User control: Any control inheriting from UserControl class; These types of controls have a markup associated with them and can have code-behind based on the type of project you have (whether your project is a website or a web application). These controls are not good for re-usability across projects. They are very good candidates to be used as Views in MVC (Model-View-Controller).

Custom control: Any control inheriting from Control, or WebControl or CompositeControl or DataBoundControl or some other base classes in .NET. These controls don't have associated markup with them. They are pretty good for being encapsulated inside a DLL and being reused across multiple projects. Custom controls usually need more understanding of how web works and you usually overwrite CreateChildren or Render method to determine the output of the control.

share|improve this answer
add comment

User Control These are the existing controls of the framework and are used in conjunction with other controls to facilitate certain actions like Login Control

Custom Control In this case you inherit from the available control and add features which are customized for that control and your needs. something like a datepicker Column in the DataGridView

share|improve this answer
    
So simply put, without working in Microsoft, I wont be able to create any Uswer Control, but only to use them, but can create Custom Controls, right? –  Shamim Hafiz Aug 19 '11 at 10:13
add comment

I don't know if there is a useful distinction between them in the winforms world, but in asp.net (web forms) this is the distinction:

A usercontrol can have declarative markup in a XXXX.ascx file whereas logic is placed in the corresponding XXXX.ascx.cs file. Whenever you want to use the usercontrol you must declare which ascx-file you want to use.

A Custom Control can't have declarative markup, but can be used by just specifying the namespace (for example globally in web.config)

or more succinctly: a usercontrol is mucht easier to write but slightly harder to use, a custom control is (potentially) much harder to write but slightly easier to use.

All the builtin controls shipped from MS are custom controls which makes them easier to use (you don't have to specify an ascx-file to use an asp:Label for instance)

Generally: if you are going to make a control which consists of many sub-controls you would want to go with usercontrol, but if you are extending a standard control with some new logic you'd want to go with custom control

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.