shshva

shshva

  • NA
  • 37
  • 18.9k

How to display master pages dynamically based on user

Jan 26 2012 1:19 AM
Hi,

I have three roles engineer,supuvisor and manager for my website

and I have three master pages engineer.master , supervisor.master and mgr.master
and i have some specific aspx pages for engineer,supervisor and manager.

I want to use engineer.master page for an aspx page if engineer user is logged in and want to use supervisor.master page if supervisor logged in ans so on for the manager.
How can I achieve this?

Thanks in advance!!!

Im getting error

here is the code :
protected override void OnPreInit(EventArgs e) {
base.OnPreInit(e);
switch (Session["role"].ToString())
{
case "1":
MasterPageFile = "ME.Master";
break;
case "2":
MasterPageFile= "Supervisor.Master";
break;
case "3":
MasterPageFile = "Manager.Master";
break;

default:
MasterPageFile = "default.Master";
break;
}

Thank you


Answers (3)