tags:

views:

45

answers:

2

Is it possible to assign a Master Page dynamically?

+5  A: 

Assign the master page in PreInit of the page whos MasterPage you wish to dynamically set:

protected void Page_PreInit(Object sender, EventArgs e)
{
    this.MasterPageFile = "~/YourMaster.master";
}
GenericTypeTea
seems so simple, i like it
Spooks
+1  A: 

You can assign the master page during the Page_PreInit by using the MasterPageFile property.

Me.MasterPageFile = "~/masterpage.master"
Jake1164