How do you dynamically assign a Master Page?
Is it possible to 开发者_开发知识库assign a Master Page dynamically?
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";
}
You can assign the master page during the Page_PreInit
by using the MasterPageFile
property.
Me.MasterPageFile = "~/masterpage.master"
精彩评论