Efficient way to load user control from dll during runtime in c# csharp .net
Posted on 2009-03-31
I have created a user control library of composite user controls, each with a few simple buttons.
During runtime, I am able to load and unload these controls. I expect to have hundreds of these controls, and depending on user selections a different user control will be loaded.
The thing is, how do I do this without creating a giant IF-ELSE statement? I thought about storing some info in a database, but I'm not sure what info to put in the DB that I can use to actually instantiate the user control in the dll.
In other words, I know I can: myCustomUserControl X = new myCustomUserControl(), and add via to MyPanel.Controls.Add(X) ..... but, how can I do the same thing using a database that will have some kind of reference to the myCustomUserControl in the DLL?
This way, I could do a DB lookup, and then a load, instead of a huge Switch or If-Else...
can anyone help??