响应。按级别重定向 [英] Response. Redirect by levels

查看:61
本文介绍了响应。按级别重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同级别上有不同的用户。当用户登录时,他们将被定向到他们的主页或欢迎页面。在那里,他们可以点击链接转到另一个页面并填写。填写完表单后,用户单击提交并保存数据,并将用户重定向回其欢迎页面。我试图让不同的用户重定向到他们自己的欢迎页面。现在我让他们重定向到他们刚刚填写的同一页面。是否可以为用户提供不同级别的此功能?



这是我到目前为止的代码:



I have different users on different levels. When a user logs in they are directed to their home page or welcome page. There they can click on a link to go to a different page and fill it out. Once the form is filled out the user clicks on submit and the data is saved and the user is redirected back to their welcome page. I am trying to get the different users to redirect to their own welcome page. Right now I have them to redirect to the same page they just filled out. Is it possible to do this with different levels for users?

Here is the code I have so far:

protected void Button1_Click(object sender, EventArgs e)
    {
 
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DepartConnectionString"].ConnectionString);
        con.Open();
 

 

        if (true)
        {
            SqlCommand level = new SqlCommand("select accessLevel, Password, INST_ID from Table22 where EmailAddress = @EmailAddress AND Password = @Password", con);
            level.Parameters.Add(new SqlParameter("EmailAddress", TextBoxEA.Text));
            level.Parameters.Add(new SqlParameter("Password", TextBoxPW.Text));
 
            SqlDataReader reader = level.ExecuteReader();
            DataTable dt1 = new DataTable();
            dt1.Load(reader);
 
            foreach (DataRow dr1 in dt1.Rows)
            {
                int returnedLevel = Convert.ToInt32(dr1[0].ToString());
                int inst_id = Convert.ToInt32(dr1[2].ToString());
                Session["inst_id"] = inst_id;
                    
                if (returnedLevel == 1)
                {
                    Response.Redirect("FormAPublic.aspx");
                }
                else if (returnedLevel == 2)
                {
                    Response.Redirect("FormCPrivateNon.aspx");
                }
                else if (returnedLevel == 3)
                {
                    Response.Redirect("FormDPrivateFor.aspx");
                }
                else if (returnedLevel == 7)
                {
                    Response.Redirect("CEOPage.aspx");
                }
                else if (returnedLevel == 8)
                {
                    Response.Redirect("DBPage.aspx");
                }
                else if (returnedLevel == 11)
                {
                    Response.Redirect("FormAPublicL.aspx");
                }
                else if (returnedLevel == 21)
                {
                    Response.Redirect("FormCPrivateNonL.aspx");
                }
                else if (returnedLevel == 31)
                {
                    Response.Redirect("FormDPrivateForL.aspx");
                }
                
            }





我会把它放在我所拥有的代码的底部保存数据。



I will put this at the bottom of the code I have for saving the data.

推荐答案

是的,这是可能的。



维护<的级别状态列code> sql 。

例如。

当用户级别为公共插入状态为1时,私有为2,依此类推。然后从表格中获取价值



检查这就像你在问题中所做的那样

Yes it is possible.

Maintain a status column for levels in sql.
For eg.
when user level is public insert status as 1,private as 2 and so on.Then get the value from table

check this like you did it in your question
if(status==1)
{
Response.Redirect("Public.aspx")
}
if(status==2)
{
Response.Redirect("private.aspx")
}


这篇关于响应。按级别重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆