I managed to get this to work using the following code:
public class MasterLoader : UserControl
{
MasterUserControl _masterUserControl;
protected override void CreateChildControls()
{
Controls.Clear();
base.CreateChildControls();
Controls.Add(MasterControl);
}
protected override void AddedControl(Control control, int index)
{
if (control is MasterUserControl)
base.AddedControl(control, index);
else
MasterControl.ContentArea.Controls.Add(control);
}
private MasterUserControl MasterControl
{
get
{
if (_masterUserControl== null)
_masterUserControl= (MasterUserControl)LoadControl("~/MasterUserControl.ascx");
return _masterUserControl;
}
}
}
Child user controls inherit from the MasterLoader class. The master user control included a placeholder control that I exposed as a public property called ContentArea.
public partial class MasterUserControl: UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public PlaceHolder ContentArea
{
get
{
return phContent;
}
}
}
Event binding and view state work as expected without any changes to any of the user controls.