tags:

views:

4620

answers:

3

What is the difference, what is the official terms, are any terms obsolete in ASP.NET 3.5?

+5  A: 

UserControl: A custom control, ending in .ascx, that is composed of other web controls. Its almost like a small version of an aspx webpage. It consists of a UI (the ascx) and codebehind. Cannot be reused in other projects by referencing a DLL.

WebConrol: A control hosted on a webpage or in a UserControl. It consists of one or more classes, working in tandem, and is hosted on an aspx page or in a UserControl. WebControls don't have a UI "page" and must render their content directly. They can be reused in other applications by referencing their DLLs.

RenderedControl: Does not exist. May be synonymous to WebControl. Might indicate the control is written directly to the HttpResponse rather than rendered to an aspx page.

CompositeControl: Inbetween UserControls and WebControls. They code like UserControls, as they are composed of other controls. There is not any graphical UI for control compositing, and support for UI editing of CompositeControls must be coded by the control designer. Compositing is done in the codebehind. CompositeControls can be reused in other projects like WebControls.

Will
Actually a Composite control does NOT have a UI - you rely entirely on filling its Controls collection with other controls.Rendered controls are a kind of composite controls where you do not reuse other controls but merly override the Render method to output pure text (html)
Per Hornshøj-Schierbeck
I double checked my reference and clarified my CompositeControl definition, thanks. But I cannot find any official mention of a RenderedControl in MSDN documentation. Do you have a link on that? I agree on your assessment of what it probably means...
Will
+3  A: 

You've forgotten the ServerControl.

In my understanding it is like that:

  • There are only two different kind of controls: UserControl and ServerControl
  • CompositeControls are kind of "advanced" UserControls. Find some more info on Scott Guthries Blog.
  • All of them are WebControls (because they are all derived from System.Web.UI.Control)
  • They are all rendered in any way so i would like to see them all as rendered controls.

From MSDN:

User Control

In ASP.NET: A server control that is authored declaratively using the same syntax as an ASP.NET page and is saved as a text file with an .ascx extension. User controls allow page functionality to be partitioned and reused. Upon first request, the page framework parses a user control into a class that derives from System.Web.UI.UserControl and compiles that class into an assembly, which it reuses on subsequent requests. User controls are easy to develop due to their page-style authoring and deployment without prior compilation.

Server control

A server-side component that encapsulates user interface and related functionality. An ASP.NET server control derives directly or indirectly from the System.Web.UI.Control class. The superset of ASP.NET server controls includes Web server controls, HTML server controls, and ASP.NET mobile controls. The page syntax for an ASP.NET server control includes a runat="server" attribute on the control's tag. See also: HTML server control, validation server controls, Web server control.

JRoppert
UserControl != CompositeControl.http://weblogs.asp.net/scottgu/archive/2006/01/29/436854.aspx
Will
Yep, you are right. I've learned something today. I have changed that in my answer.
JRoppert
I don't think this is quite right. UserControl and WebControl are both types of Server Control. (In the text you quote it actually says that UserControl is a Server Control). I think perhaps a "Server Control" just means any control with runat=server. Also, UserControl is not a WebControl. UserControl inherits from TemplateControl which inherits from Control, whereas WebControl is a different class that Inherits from Control. CompositeControl inherits from WebControl, but implements INamingContainer and ICompositeControlDesignerAccessor which make it more like a UserControl.
Tim Goodman
Then again, I could be mistaken in using the WebControl *class* as synonymous for "Web Control" (with a space) . . . adding confusion, some pages on MSDN (see http://msdn.microsoft.com/en-us/library/aa651710(VS.71).aspx) use the terms "Web User Control" to refer to "UserControl" and "Web Custom Control" to refer to "WebControl". I've just double checked and these longer names are also what's used in the VS Templates (when I Add Item... in Solution Explorer)
Tim Goodman
A: 

Since I don't have enough reputation yet to comment, I'll add this as an answer, but it refers to Will's answer above.

From the link you included:

Composite controls are the right tool to architect complex components in which multiple child controls are aggregated and interact among themselves and with the outside world. Rendered controls are just right for read-only aggregation of controls in which the output doesn't include interactive elements such as drop-down or text boxes.

I believe the documentation is refering to UserControls that have been created by overriding the Render method as Rendered Controls. Thus, it is not a separate type as the question implies, but a way of implementing a UserControl; a pattern.

Don