Creating Dynamic User Controls

Having known how to create a user control, you should also know how to add it to the web page where it is required. If the page in which the user control is added is not known and you have to dynamically add the user control to the page then you have to use some other method to do it.

To load a user control to the page, you have to use the LoadControl method in the Page_Load event. The LoadControl event takes the name of the user control as its argument and then loads the user control to the page.

Then you can easily add it to the controls collection using the Controls.Add method. However with this you may not know where this user control will be positioned. So you need a placeholder or something like a panel control where you are add the user control.

For example to add the user control dynamically to the placeholder, you can use the following command syntax,

PlaceHolder_Ctrl.Controls.Add(name_of_UserControl);

There are many samples available in the internet on how to add the user control dynamically to the web page.


Introducing the Multi-Talented New Citroen DS4
SLOUGH, UNITED KINGDOM – Aug 30, 2010: Citroen has released first details for the new DS4, a unique and attractive blend of creativity, dynamism, exclusivity and versatility. DS4 is the second model in Citroën's distinctively-styled DS line.

A Few Rallies with Virtua Tennis 4 and PlayStation Move
As dark clouds have taken residence over London and the weather resembles a certain interactive drama, I don't think I'll be stepping onto a tennis court any time soon. Luckily, I have a PlayStation Move motion controller, a 3D TV and an early demo of Virtua Tennis 4 to tide me over. I recently spoke [...]

iPortal Set To Change The Lives Of Wheelchair User
Christchurch, NZ – August 25, 2010 – Dynamic Controls today announced its innovative iPortal is now available worldwide. The iPortal solution connects powered wheelchairs to the internet using an iPhone or iPod in a special mount and also includes a ‘chair ...




______________________________________________________

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 |



_______________

FREE Subscription

Stay Current With the Latest Technology Developments Realted to .NET. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.


 

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