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; } }
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5