Click here to Skip to main content
14,732,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a application which has 2 types of users, one is admin and other normal user. I want to create 2 separate master pages for Admin and Normal user. and also can i use same forms in both the master pages?

code i am working on is:
    SqlConnection con=new SqlConnection(@"Data Source=ashish-pc\;Initial Catalog=HMS;Integrated Security=True");
    SqlCommand cmd = new SqlCommand("select * from Login where UserName=@UserName and Password=@Password", con);
    cmd.Parameters.AddWithValue("@UserName", UserName.Text.Trim() );
    cmd.Parameters.AddWithValue("@Password", Password.Text.Trim());

    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
   // DataSet dt = new DataSet();
    DataTable dt = new DataTable();
    if (dt.Rows.Count>0)
        Session["UserName"] = UserName.Text;
        Session.Timeout = 10;
        if (dt.Rows[0]["SuperUser"].ToString() == "True")



         Response.Write("Invalid username and password");

please help me out

1 solution

My solution is do not create two seperate master forms. Insted of this create nested master form inside main master form. Then you can use the base master form to all the web forms which in turn nested also comes into this case.

For more info on nested master form please refer[^]

not necessary code block removed

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