Hello i have a Usercontrol with Constructor
public Person(String Id, String Name)
i want to load this UserControl as isntance like:
Control tmpControl = (Person)LoadControl(typeof(Person), new object[] { Id, Name});
the instance of the .cs work but the usercontrol controls are all null.
if i do:
Control tmpControl = (Person)LoadControl("Person.ascx");
i have controls in the instance but he use the default empty construcor.
How to get booth the correct controls and class instance ???
One other try is:
Control tmpControll = (new Person(Id, Name)).LoadControl("Person.ascx");
this work as follows: (new Person(Id, Name)) = new class inctance and .LoadControl("Person.ascx") makes again a clompete new instance that means the first line do the right instance but is overwritten by the secound part
I dont want the example:
Control c = Page.LoadControl("/UserControl/webMenu.ascx");
webMenu a = (webMenu)c;
a.Title = "This is a Title";
this is not really what i want !!!!!!!!!!!
Person tmpControl = new Person(Id, Name);?Controlscollection of the parent you want it to have. Probably advisable to do this early enough in the page lifecycle (such as Page_Init) that the control gets persisted across postbacks.