Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Set Master Page dynamically?


I have requirement in which i want to set different Master Pages for the Same Page depending upon userid(i.e. for one user it must set one master page and for another user it must set another master ).Can we set different Master pages for any page dynamically?Please help...

like image 522
Amol Kolekar Avatar asked Jun 07 '12 11:06

Amol Kolekar


1 Answers

void Page_PreInit(Object sender, EventArgs e)
{
    this.MasterPageFile = "~/MyMaster.master";
}

Explanation: You can attach a master page dynamically to a content page. Because the master page and content page are merged during the initialization stage of page processing, a master page must be assigned before then. Typically, you assign a master page dynamically during the PreInit stage.

like image 100
Kapil Khandelwal Avatar answered Sep 27 '22 18:09

Kapil Khandelwal