开发者

Initialization in Asp.NET Master Page

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="MasterFoo开发者_开发技巧ter" 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) 
  1. Where is the best Page event to put the codes above?
  2. Do I need to put something in the page directive to make it work?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜