If your control is mostly dynamically generated — for instance rows of a data-bound table, nodes of a tree view, or tabs of a tab control — a custom control would be a better choice.
Net Articles ASP. Web User Control: Web user controls are easy to make, but they can be less convenient to use in advanced scenarios. Web Custom 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.
The main differences between the two types are outlined in this table: Web user controls Web custom controls 1. Easier to create 1. Harder to create 2. Limited support for consumers who use a visual design tool 2. Full visual design tool support for consumers 3. A separate copy of the control is required in each application 3.
Only a single copy of the control is required, in the global assembly cache 4. Control class. You may derive from a different custom control depending on your requirement. A UserControl inherits from the System. UserControls class, which inherits from the base "Control" class.
Custom control is designed for single-application scenarios because if the same control needs to be used in more than one application, it introduces redundancy and maintenance problems. While UserControl designed so that it can be used by more than one application.
It can distributed easily and without problems associated with redundancy and maintenance. CustomControl is a loosely coupled control w. Control class. You may derive from a different custom control depending on your requirement.
Custom Controls are compiled into a DLL assembly and can be reused in multiple places very easily. You have total control over the code, thus gives you more flexibility to extend the behaviour. Once you build and add a reference of the custom control in your project, you can find it in the toolbox. Thus, you will be able to drag and drop the control in your Design view and start working with it very easily. The base " UserControl " is nothing but a Custom Control that you derive to create a control UI specific to your project.
You can directly access its UI elements from the code-behind and do some specific operations. A custom UserControl inherits from the System. UserControls class, which inherits from the base " Control " class. You can't create theming support for UserControl s but can style them by creating themes for the child Custom Controls because they represent a collection of controls.
Once you create a UserControl UI in one project, you can't change it in other projects. Let's summarize the differences again. Read the comparison below to make things clear:.
0コメント