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

Recommended Answers

All 8 Replies

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, if supervisor(user) log on and will direct to supervisor.master page
same goes to Engineer.. and Manager.
3 roles have different master page(coz 3 of them have different content)
How can I achieve this?

Thanks in advance!!!

If your're storing the user details in arrays you can add an int field to the array called somethin like AuthLevel and use 1, 2 or 3 as the different roles. One logging in you would do a check to see if the user exists and depending on the value of that user's AuthLevel field.

If your using an connected database it would be easier, especially if your going to be storing data entered into the different forms.

Hope this helps

Sorry i dont get you.

public partial class ME0 : System.Web.UI.Page {
  sqlDataContext sdc = new sqlDataContext();

  protected override void OnPreInit(EventArgs e) {
   base.OnPreInit(e);
   employee emp = Cache["emp"] as employee;


   switch (Session["role"].ToString() ) 
   {

        case "1":
        MasterPageFile = "Engineer.Master";
        break;
        case "2":
        MasterPageFile= "Supervisor.Master";
        break;
        case "3":
        MasterPageFile = "DOD.Master";
        break;
        default:
        MasterPageFile = "Manager.Master";
        break;
 }

i was suggesting a solution that uses arrays to store user details but if you're using a a database that will be easier.

If i understand you correctly you want a different form to be loaded depending on the type of user that logs in (engineer, supervisor, manager). Simply add a column to the user table to store the different types of user and then during the check to see if the user exists simply check whether they are a manager, supervisor or engineer and load the appropriate form.

Yes Im using database..

this is the error im getting...Exception Details: System.Web.HttpException: The file '/Manager.Master' does not exist.

found the solutions..thanks everyone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.