开发者

Programmatically define a nested masterpage's master, Is it possible?

Currently I have a site that is set up using a masterpage and a nested master page. The master page s开发者_如何转开发etups up the header and footer info. The nested masterpage is used once logged into the site.

The issue I have is that I want to programmatically load a different masterpage to define different header and foot info.

I don't think I can use the OnPreInit() in each content class to set a different masterpage. I don't think I can do this because each Content page uses the Nested Masterpage.

What I would like to do is programmatically set which masterpage is called in the NestedMaster.

Any ideas? I saw this blog posted on another MasterPage question. Before trying this route I wanted to see if anyone else has experienced this.

Thanks

EDIT: In the CS page:

public class AdminBasePage : BasePage 
{ 
     protected override void SetMasterPageFile() 
     { 
          Page.Master.MasterPageFile = "~/PathToMaster/Site.Master"; 
     } 
} 


Look here:

Nested Master Pages


Page.Master.MasterPageFile = "~/PathToMaster/Site.Master";

(Thanks for the answer Ken and Brad, however I read most of that long tutorial before spotting the simple one line of code had been added to your question, so am making it more obvious by adding it as an answer here and will edit your post. Cheers)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜