I have a user control that loads other user controls dynamically. The issue is that on postback my controls don't exist. Now i'm under the impression i have to re-initialize them.
Now to do this since they're UserControls and use the ascx file none of the UserControl's controls have been initialized in the empty constructor.
Question: How do i load the UserControl's ascx file at this time?
Currently i'm trying to do it like this:
for (int i = 0; i < count; i++)
{
Control ctrl;
if(ctrlCollectionType.Rows[i]["Type"] is UserControl)
ctrl = LoadControl((string)ctrlCollectionType.Rows[i]["Path"]);
else
this.LoadControl(ctrlCollectionType[i]["Type"], null);
ctrl.ID = i;
pnlContent.Controls.Add(ctrl);
}
Where ctrlCollectionType is the Type of the userControl.
Edit: Solution as per Joel Coehoorn's input.