Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Dynamically Loading User Controls

Reply
Thread Tools

Dynamically Loading User Controls

 
 
B. Suitt
Guest
Posts: n/a
 
      04-16-2008
In ASP.Net 1.1 dynamically loading user controls was very simple, however
with the 2.0+ framework I apparently can not use the same code to accomplish
the same thing and I have not found any examples of how to make it work.

My example code is as follows:

Dim MyControl As Web.UI.Control

MyControl = LoadControl("testcontrol.ascx")
PlaceHolder1.Controls.Clear()
MyControl.ID = "CurrentControl"
PlaceHolder1.Controls.Add(MyControl)

The control will display properly on the screen using the above code,
however if I click on a button that resides inside of the user control, no
event is fired and the control itself just disappears. For the project that
I am working on, it's not an option to load potentially 50 user controls and
just hide and display them. I really need to be able to load them
dynamically.

I'm sure lots of people have encountered this problem by now and no doubt
have the solution. Thanks in advance!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues in ASP.NET 2.0 when dynamically loading user controls or asp.net web controls??? Bob Rock ASP .Net 1 09-17-2006 01:49 PM
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
loading user controls dynamically Nick Stansbury ASP .Net 1 07-19-2004 12:38 PM
when loading user controls dynamically, problem on postback sonic_soul ASP .Net 0 08-14-2003 10:05 PM
Re: Loading/Unloading web user controls dynamically in code - Does this look right? Ben Miller [msft] ASP .Net 0 08-05-2003 05:57 AM



Advertisments