Torna al Thread
public class myCustomPage :Page
{
public myCustomPage()
{
}
protected UserControl LoadControl(string UserControlPath, params object[] parametriCostruttore)
{
List<Type> values = new List<Type>();
foreach (object param in parametriCostruttore)
{
values.Add(param.GetType());
}
UserControl myCtrl = Page.LoadControl(UserControlPath) as UserControl;
System.Reflection.ConstructorInfo costruttoreMyCtrl = myCtrl.GetType().BaseType.GetConstructor(values.ToArray());
if (costruttoreMyCtrl == null)
throw new MemberAccessException("Costruttore non trovato" + myCtrl.GetType().BaseType.ToString());
else
costruttoreMyCtrl.Invoke(myCtrl, parametriCostruttore);
return myCtrl;
}
}