如何根据特定用户的登录类型隐藏特定菜单?我有主页。
我想要的是隐藏一些菜单为每个用户基于他们的登录类型。
如果
我的登录代码是这样的
protected void btnLogin_Click(object sender, EventArgs e)
{
//Response.Redirect("~//Administration/DashBoard.aspx");
SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DebitCareBankApp;Data Source=SSDEV7-HP\\SQLEXPRESS");
string cmdStr = "select LoginType from Login where UserName='" + TxtUserName.Text + "' AND Password = '" + TxtPassword.Text + "'";
SqlCommand cmd = new SqlCommand(cmdStr, con);
con.Open();
Object TypeUser = cmd.ExecuteScalar();
con.Close();
//int switchcase = int.Parse(TypeUser);
if (TypeUser != null)
{
LblError.Visible = false;
LblError.Text = "";
if (TypeUser.ToString() == "Manager")
{
Response.Redirect("~//Administration/Manager/WorkManagement.aspx");
}
else if (TypeUser.ToString() == "HR")
{
Response.Redirect("~//Administration/Hr/CalculateAndGeneratePayslips.aspx");
}
else if (TypeUser.ToString() == "Employee")
{
Response.Redirect("~//Administration/CallingAgent/TodaysWork.aspx");
}
}
else
{
LblError.Visible = true;
LblError.Text = "Invalid Credentials Entered, Try again";
}
}
发布于 2012-02-13 13:29:05
我过去曾为此目的使用过数据库表。我以前在数据库中存储菜单和角色,然后根据记录的用户询问它们,然后创建菜单。
这通常是可行的,但如果你能告诉我你创建菜单的方式,我可以详细说明我的答案。请添加作为评论。
问候
https://stackoverflow.com/questions/9261114
复制相似问题