Working on .NET User Controls with Your Code

User controls help you combine different control and form a single control. This single control will encompass the other controls needed for the functionality needed. So by dragging and dropping a single control, you are actually including a lot of different controls that gives a complex functionality.

This helps you to modularize the development of your project since you can combine controls and codes to form a user control. Anything that can be combined and used in different places in your project should be created as a user control for ease of use and for speeding up your development.

By using the LoadControl and the Control.Add method you can add user controls dynamically through code when you are running your program. To add such user controls dynamically you need a placeholder to add.

This placeholder is added to your page during design time to enable you to add the user control during runtime. You can also use the set and the get routine to set the properties for your controls available in the user control.

PlaceHolder_Ctrl.Controls.Add(name_of_UserControl);

The above syntax will add a user control using the Controls.Add method into a PlaceHolder control that was placed in your page during design time.





______________________________________________________

Recommended Resource



| Converting Web Pages to User Controls in .NET | .Working on .NET User Controls | Overview of ASP.NET User Controls | Web User Controls - Creation and Implementation | Advantages of using User Controls in ASP.NET | Re-usability of User Controls in ASP.NET | Personalizing Web Application by Creating User Controls in .NET | Customizing your Application with VB.net User Controls | Building User Controls in ASP.NET | Examples of User Controls in VB.NET | Example of C# User Controls | Where to use Visual Basic User Controls | Working on User Interface Controls | Creating Dynamic User Controls | Understanding VB .NET User Controls | Creating User Controls VB.NET | How to load user controls dynamically |

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2024 - All Rights Reserved.