Dynamically adding web user controls asp.net 2.0
Dynamically adding controls to the page in asp.net 2.0 is very different to what it was in asp.net 1.1
The technique I'm eplaining here is probably not the best way to do this, but this works good and is one of the suggested techniques on the microsoft forum.
The problem is that u can not use the user controls anymore like we where used to in 1.x. As I comprehended from the forum, there is no dll file to reference to. So without a reference, you cannot create a new control like :
Dim myControl as new MyNewControl()
So, the way I made this possible is to put in a contract file, read an interface. Our control will implement the Interface. At the end you can use the following syntax :
Dim myControl As IControlBase = LoadControl("MyNewControl.ascx")
myControl .DoSomething()
myControl.Language = "nl"
and eventually
PlaceHolder.Controls.Add(myControl )
If you have a better and faster technique, feel free to let me know.