EnsureChildControls
EnsureChildControls is something useful to keep in mind when creating properties that get/set properties on controls present in, for example, a web form or master page. If the control has not yet been created, you will get a runtime error. What EnsureChildControls does is checks if the child controls have been created, and if not creates them.
public bool MainMenuVisible
{
get
{
EnsureChildControls();
return MainMenu.Visible;
}
set
{
EnsureChildControls();
MainMenu.Visible = value;
}
}




