using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
protected void Button1_Click(object sender, EventArgs e){
SqlConnection con = new SqlConnection(@"Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand("select COUNT(*) FROM Registration WHERE Username='" + TextBox1.Text + "' and Password='" + TextBox2.Text + "'");
cmd.Connection = con;
int OBJ = Convert.ToInt32(cmd.ExecuteScalar());
if (OBJ > 0)
{
Session["name"] = TextBox1.Text;
Response.Redirect("Userdefaultpage.aspx");
}
else
{
Label1.Text = "Invalid username or password";
this.Label1.ForeColor = Color.Red;
}
con.Close();
}

Ranjeet PatraPosted Apr 17, 2017, 1:21 AM