I need to do a dynamically loaded Header and Footer on Master page where there are two placeholders to store the users controls which will become the Headers and Footers. The reason why I am doing it to make it more customizable and it is the how it is required from my supervisor as well.
So I have two key-value in web.config such as
<add key="MasterHeader" key="~/Controls/Header.ascx"/>
<add key="MasterFooter" key="~/Controls/Footer.ascx"/>
So I am wondering which Page event should I load these users controls by saying
UserControl uc = (UserControl) Page.LoadControl(ConfigFile.MasterHeader))
PlaceHolder1.Controls.Add(uc)
I would use OnPreInit or OnPreLoad. You shouldn't need to put anything in the page directive to make this work, the way you're describing it.