What are composite custom controls?
Composite custom controls combine one or more server or HTML controls within a single control class, which can be compiled along with other control classes to create an assembly (.dll) that contains a custom control library. Once created, the custom control library can be loaded into Visual Studio .NET and used in the same way as the standard server and HTML controls.
Composite custom controls are functionally similar to user controls, but they reside in their own assemblies, so we can share the same control among multiple projects without having to copy the control to each project, as we must to do with user controls. However, composite controls are somewhat more difficult to create because we can’t draw them visually using the Visual Studio .NET Designer.
What are the steps to follow create and use a custom control in a Web application?
1. Create a solution containing a custom control project.
2. Add a Web application project to the solution, and set it as the startup project. You will use the Web application project to test the custom control during development.
3. Add a project reference from the Web application to the custom control project, and add an HTML @Register directive and control element to use the custom control on a Web form.
4. Create the custom control’s visual interface by adding existing controls to it through the customs control’s Create Child Controls method.
5. Add the properties, methods, and events that the custom control provides.
6. Build and test the custom control.
Composite custom controls are functionally similar to user controls, but they reside in their own assemblies, so we can share the same control among multiple projects without having to copy the control to each project, as we must to do with user controls. However, composite controls are somewhat more difficult to create because we can’t draw them visually using the Visual Studio .NET Designer.
What are the steps to follow create and use a custom control in a Web application?
1. Create a solution containing a custom control project.
2. Add a Web application project to the solution, and set it as the startup project. You will use the Web application project to test the custom control during development.
3. Add a project reference from the Web application to the custom control project, and add an HTML @Register directive and control element to use the custom control on a Web form.
4. Create the custom control’s visual interface by adding existing controls to it through the customs control’s Create Child Controls method.
5. Add the properties, methods, and events that the custom control provides.
6. Build and test the custom control.
In general, what is the base class for every composite custom control?
System.Web.UI.WebControls.WebControl
Which directive is used to add a custom control to a Web form?
Register directive.
What are the 3 Register directive's attributes?
TagPrefix
This name identifies the group that the user control belongs to. For example, the tag prefix for ASP.NET server controls is “asp”. We use this prefix to create a naming convention to organize our custom controls.
Namespace
This is the project name and namespace within the custom control assembly that contains the controls to register.
Assembly
This is the name of the assembly (.dll) containing the custom controls. The control assembly must be referenced by the Web application. Referencing the assembly maintains a copy of it in the Web application’s /bin directory.
What are the differences between User Controls and Custom Controls?
1. User Controls are easy to create whereas Custom Controls are difficult to create.
2. User Controls cannot be compiled into an assembly, whereas Custom Controls can be compiled into an assembly.
3. User Controls cannot be added to the tool box, whereas Custom controls can be added to the toolbox.
4. We need to have a copy of user control in every project where we want to use it, whereas this is not the case with custom controls. We can install a single copy of the custom control in the global assembly cache and share it between applications, which makes maintenance easier.
5. User controls are used for reusing existing user interface elements and code, but Costume control is not useful for developing reusable components for multiple web applications.
System.Web.UI.WebControls.WebControl
Which directive is used to add a custom control to a Web form?
Register directive.
What are the 3 Register directive's attributes?
TagPrefix
This name identifies the group that the user control belongs to. For example, the tag prefix for ASP.NET server controls is “asp”. We use this prefix to create a naming convention to organize our custom controls.
Namespace
This is the project name and namespace within the custom control assembly that contains the controls to register.
Assembly
This is the name of the assembly (.dll) containing the custom controls. The control assembly must be referenced by the Web application. Referencing the assembly maintains a copy of it in the Web application’s /bin directory.
What are the differences between User Controls and Custom Controls?
1. User Controls are easy to create whereas Custom Controls are difficult to create.
2. User Controls cannot be compiled into an assembly, whereas Custom Controls can be compiled into an assembly.
3. User Controls cannot be added to the tool box, whereas Custom controls can be added to the toolbox.
4. We need to have a copy of user control in every project where we want to use it, whereas this is not the case with custom controls. We can install a single copy of the custom control in the global assembly cache and share it between applications, which makes maintenance easier.
5. User controls are used for reusing existing user interface elements and code, but Costume control is not useful for developing reusable components for multiple web applications.
No comments:
Post a Comment