R – Programmatically define a nested masterpage’s master, Is it possible

asp.netmaster-pagesnested

Currently I have a site that is set up using a masterpage and a nested master page. The master page setups 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"; 
     } 
} 

Best Answer

Look here:

Nested Master Pages