how i can redirect from my login page to home page after the login is success? I have one database in this it stores the username and password. at the time of login it wil check the user name and password by sql query. my code is shown below.
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{
Label3.Visible = true;
Label3.Text = "* Required Field";
}
else if (TextBox2.Text == "")
{
Label4.Visible = true;
Label4.Text = "* Required Field";
}
else
{
Label3.Visible = false;
Label4.Visible = false;
userid = TextBox1.Text;
pass = TextBox2.Text;
SqlConnection conn = new SqlConnection("SERVER= BAYONE003\\OFFICESERVERS; Initial catalog = Web; Integrated Security = SSPI");
SqlCommand mycmd = new SqlCommand();
mycmd.Connection = conn;
mycmd.CommandText = "SELECT FirstName, LastName, MiddleName, Email, Age FROM web WHERE IsActive=1 AND LoginName='" + userid + "' " + "AND Password='" + pass + "'";
try
{
conn.Open();
mycmd.ExecuteScalar();
SqlDataAdapter da = new SqlDataAdapter(mycmd);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.Visible=true;
GridView1.DataSource = dt;
GridView1.DataBind();
TextBox1.Text = "";
TextBox2.Text="";
}
finally
{
conn.Close();
conn.Dispose();
}
}
}
My requirement is that if the login successful i hav to redirect from login page to the home page instead of gridview binding. how it eill be done?