Creating User Controls VB.NET

You can create user controls by combining other controls into a single control. The user controls can be created by creating a new project of type Web Control Library using the Visual Studio .Net.

The file created with this type of project will have an extension of .ascx. Once you create this type of project you can add the necessary controls to the page in the design view.

If you look at the code in the code view you will find a @control directive instead of the @page directive which you find in the web pages. Use the get and the set routines to create properties for the user control.

The user control that you have created is compiled to a DLL file. If you want to include it in a project just place it in the bin directory of the application and you can use it in your project.

To place the user control in the toolbox, right click the tool palette and select customize. Now browse to the user control DLL file and add it.

The user control will now be placed in the tool palette. Now you can add the user control at design time by simply dragging and dropping the user control as you would work with other controls.

You can also add user controls dynamically to a placeholder by using the Controls.Add method. Before that you have to load the user control using LoadControl method.