First Insert these lines at the top of your code bind file.
using System.Data;
Second step is to write this code in signin button event
protected void btnSignIn_Click(object sender, EventArgs e)
{
String struserid = txtuserid.Text;
String strpassword = txtpassword.Text;
if (struserid == "" && strpassword == "")
{
Label1.Text = "Please Valid User ID";
Label2.Text = "Please Fill Valid Password";
}
else
{
SqlConnection con = new SqlConnection();
con.ConnectionString = _connStr;
String strselect = "select userid,password from profiledata where userid='" + struserid + "' and password='" + strpassword + "'";
con.Open();
SqlCommand cmd = new SqlCommand(strselect,con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["sessionuserId"] = struserid;
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('mygallary.aspx','frame1');", true);
}
else
{
Label1.Text = "Please Valid User ID";
Label2.Text = "Please Fill Valid Password";
}
}
}
using System.Data;
using System.Configuration;
using System.Data.SqlClient;Second step is to write this code in signin button event
protected void btnSignIn_Click(object sender, EventArgs e)
{
String struserid = txtuserid.Text;
String strpassword = txtpassword.Text;
if (struserid == "" && strpassword == "")
{
Label1.Text = "Please Valid User ID";
Label2.Text = "Please Fill Valid Password";
}
else
{
SqlConnection con = new SqlConnection();
con.ConnectionString = _connStr;
String strselect = "select userid,password from profiledata where userid='" + struserid + "' and password='" + strpassword + "'";
con.Open();
SqlCommand cmd = new SqlCommand(strselect,con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
Session["sessionuserId"] = struserid;
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open('mygallary.aspx','frame1');", true);
}
else
{
Label1.Text = "Please Valid User ID";
Label2.Text = "Please Fill Valid Password";
}
}
}
No comments:
Post a Comment