What is the difference between UserControl, WebControl, RenderedControl and CompositeControl?

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

+49
Sep 16 '08 at 10:38
source share
5 answers

UserControl . A user control ending in .ascx, which consists of other web controls. It is almost like a small version of an aspx web page. It consists of a UI (ascx) and codebehind. Cannot be reused in other projects, referencing a DLL.

WebControl : A control hosted on a web page or in a UserControl. It consists of one or more classes working in tandem and hosted on an aspx page or in a UserControl. WebControls does not have a "page" user interface and must display their contents directly. They can be reused in other applications by referencing their DLLs.

RenderedControl : does not exist. May be synonymous with WebControl. The control may be written directly in HttpResponse and not displayed on the aspx page.

CompositeControl : between UserControls and WebControls. They are encoded as UserControls because they consist of other controls. There is no GUI for managing the composition, and support for editing the CompositeControls user interface must be encoded by the management designer. The composition is performed in code. CompositeControls can be reused in other projects, such as WebControls.

+45
16 Sep '08 at 10:56
source share

You forgot ServerControl.

In my understanding, this is so:

  • There are only two different types of controls: UserControl and ServerControl
  • CompositeControls are a kind of "advanced" UserControls. Find more information on the Scott Guthries Blog .
  • All of them are WebControls (because they are all obtained from System.Web.UI.Control)
  • They are all displayed in any way, so I would like to see them as processed controls.

From MSDN:

User control

In ASP.NET: A server control that is declarative using the same syntax as an ASP.NET page and saved as a text file with the .ascx extension. User controls allow page functionality to be split and reused. At the beginning of the request, the page structure parses user control into a class that it infers from System.Web.UI.UserControl and compiles this class into an assembly, which it reuses on subsequent requests. User controls evolve due to their authoring and deployment page style without prior compilation.

Server management

A server-side component that encapsulates the user interface and related functionality. ASP.NET server management occurs directly or indirectly from the System.Web.UI.Control class. a subset of ASP.NET server controls includes Web server controls, HTML server controls, and ASP.NET mobile controls. The page syntax for ASP.NET Server Management includes runat = "server" on the control tag. See Also: HTML Management Server, Server Checks, Web Server Management.

+8
Sep 16 '08 at 11:02
source share

Like web forms, user controls can be created in the visual designer or they can be written with code separate from HTML. They can also support execution events. However, since web user controls are dynamically compiled at run time, they cannot be added to the toolbar, and they are displayed with a simple placeholder when added to the page.

This simplifies the use of web user controls if you are used to fully supporting Visual Studio.NET development time, including the Properties window and previewing project views. Also, the only way to share user control between applications is to place a separate copy in each application, which requires additional maintenance if you make changes to the control.

Web user controls are compiled code that makes them easier to use but harder to create. Web user controls must be created in code. Once you have created the control, you can add it to the toolbar and display it in the visual designer with full support for the property window and all other ASP.NET control development time functions. In addition, you can install a single copy of a custom control in the global assembly cache and share it between applications for easier maintenance.

+3
Feb 14 '11 at 18:05
source share

Contrary to the answer, you can reuse UserControls in other projects by referencing a web deployment project .

+2
Nov 15 2018-11-21T00:
source share

Since I still do not have enough reputation to comment, I will add this as an answer, but this applies to the Answer above.

You have included in the link :

Component controls are the right tool for creating complex components in which many child controls are aggregated and interact with each other and with the outside world. The presented controls are only suitable for aggregation of read-only controls in which the output does not include interactive elements such as drop-down or text fields.

I believe the documentation refers to UserControls that were created by overriding the Render method as Rendered Controls. Thus, this is not a separate type, as the question suggests, but a way to implement UserControl; template.

0
Jun 09 '09 at 19:01
source share



All Articles