Click here to Skip to main content
14,691,021 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I have a web project that contains two logins of admin and user and also i'm having two master pages based on login type the master page has to be changed please help i'm having not an idea
Posted

There is a Event Page_PreInit which executes before your page render. You can add your code in preInit to apply master page as per your requirement.
protected void Page_PreInit(object sender, EventArgs e) 
{ 
 if (user == "admin") //check the user weather user is logged in or not
    this.Page.MasterPageFile = "~/Admin.master";
 else
    this.Page.MasterPageFile = "~/user.master";
}


For detailed description refer: this link[^]

Also refer similar QA: here[^]
   
v2
Hi,

based on login type we can change the master page dynamically.

we can achieve above point as follows.

Changing Master Page at Runtime[^]


Regards,
kiran.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900