Click here to Skip to main content
15,887,283 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
As Per Client requirement i want to show pages as per designation Here is my code .Please help me how to Redirect two different pages...

protected void ValidateUserInfo(string user, string pass)
    {

        string EmpId = txtempid.Text;
        string designation = Designationddl.Text; 
        SqlConnection con = null;
        string strConn = "Data Source=.;Initial Catalog=db_employee;User ID=sa;Password=;";
        con = new SqlConnection(strConn);
        con.Open();
        string sql = "select * from employees where EMPID=@EmpID and PASSWORDE=@Passworde";
        SqlCommand cmd = new SqlCommand(sql, con);
        cmd.Parameters.AddWithValue("@EmpID", user);
        cmd.Parameters.AddWithValue("@Passworde", pass);
        SqlDataAdapter ad = new SqlDataAdapter(cmd);
        ad.Fill(dt);


        SqlDataReader sqlRead = cmd.ExecuteReader();

        if (sqlRead.Read())
        {
            Session["EMPID"] = sqlRead["EMPID"];

        }


        if (dt.Rows.Count > 0)
        {
            Response.Redirect("employeePage.aspx");
        }
        else
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>");
            txtempid.Text = "";
            txtpwd.Text = "";
        }
        con.Close();
    }
Posted
Updated 13-Sep-13 19:51pm
v2
Comments
Mahesh Bailwal 14-Sep-13 2:19am    
It's quit simple just use if and else condition and based on that redirect to different pages using Response.Redirect.
ParameshReddy 14-Sep-13 2:23am    
if (dt.Rows.Count > 0)
{
Response.Redirect("employeePage.aspx");
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language="'javascript'">alert('Invalid Username and Password')</script>");
txtempid.Text = "";
txtpwd.Text = "";
}


Improve this code

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