Tip of the day: Set properties with reflection
If you use web sites instead of web application projects and load an user control dynamically, it can be hard to set the properties from code behind since you can´t cast the instance.
What to do? WHAAAAT TO DOOOO??? Well, first of all, take a beer and chill. After that you can take a look at reflection, and especially PropertyInfo.SetValue(...).
Magic:
using
System.Reflection;void
DoMagic(){
UserControl meLiek = LoadControl("tehcontrolz.ascx");
Type meLiekTehTajp = meLiek.GetType();
PropertyInfo prop = meLiekTehTajp.GetProperty("waevvah");
prop.SetValue(meLiek, "lolz0rz", null);
ControlHolder.Controls.Add(meLiek);
}
More info:
http://msdn.microsoft.com/en-us/library/aa330197(VS.71).aspx