Login Prob...

shreya verma posted at 12-May-08 12:53

I want to open a Different page when user login and different page when officer logins. I did this but in both cases same page means EmployeeView page will opened, how to do it???

protected void Page_Load(object sender, EventArgs e)

{

if(!Page.IsPostBack)

BindData();

}

protected void btnLogin_Click(object sender, EventArgs e)

{

string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();

SqlConnection con = new SqlConnection(constr);

con.Open();

SqlCommand cmd = new SqlCommand("Usp_CheckLogin", con);

cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.AddWithValue("@userid", txtUserID.Text);

cmd.Parameters.AddWithValue("@password", txtPassword.Text);

cmd.Parameters.AddWithValue("@role", DDRole12.SelectedValue);

SqlDataReader sdr = cmd.ExecuteReader();

if (sdr.Read())

{

if (DDRole12==User)

{

Response.Redirect("EmployeeProfile.aspx?empid=" + txtUserID.Text);

}

else if (DDRole12!=User)

{

Response.Redirect("EmployeeView.aspx?empid=" + txtUserID.Text);

}

else

{

Response.Write("Your Login Unsuccessful");

}

sdr.Close();

con.Close();

}

}

private void BindData()

{

try

{

string constr = ConfigurationManager.ConnectionStrings["ConStr"].ToString();

SqlConnection con = new SqlConnection(constr);

con.Open();

DataSet ds = new DataSet();

SqlDataAdapter sda = new SqlDataAdapter("Select distinct * from Login1", con);

sda.Fill(ds);

DDRole12.DataTextField = "Role";

DDRole12.DataValueField = "Role";

DDRole12.DataSource = ds;

DDRole12.DataBind();

con.Close();

}

catch (Exception ex)

{

Response.Write(ex.Message);

}

}




Click here to sign in and reply. You could earn money via our $500 contest just for being helpful.
  Login Prob... - shreya verma  12-May-08 12:53:53 AM
      check User variable's value... - Vasanthakumar D  12-May-08 12:58:48 AM
          See my old code... - shreya verma  12-May-08 1:08:48 AM
              Check this... - santhosh kapa  12-May-08 1:14:42 AM
              use this code... - Vasanthakumar D  12-May-08 1:19:35 AM
                  Thanks - shreya verma  12-May-08 1:22:59 AM
                  Thanks - shreya verma  12-May-08 1:23:00 AM
              Try this - npsenthil kumar  12-May-08 1:35:15 AM
      reply - Danish Shaikh  12-May-08 1:00:54 AM
      Re: Login problem - Chirag Bhavsar  12-May-08 1:08:42 AM
      See This - Sanjay Verma  12-May-08 1:40:10 AM
      Re: - chakradhar koturu  12-May-08 1:41:36 AM
View Posts