B
B. Suitt
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!
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!