using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class Default2 :
System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
}
protected void
Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
SqlCommand cmd = new
SqlCommand("select
email,Mno from GenDetails where email LIKE @email AND Mno LIKE @Mno",
con);
cmd.Parameters.AddWithValue("@email",
"'%" + TextBox1.Text + "%'");
cmd.Parameters.AddWithValue("@Mno",
"'%" + TextBox2.Text + "%'");
cmd.ExecuteNonQuery();
con.Close();
}
protected void
TextBox1_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(TextBox1.Text))
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
SqlCommand cmd = new
SqlCommand("select
email from GenDetails where email=@email", con);
cmd.Parameters.AddWithValue("@email",
TextBox1.Text);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
Label1.Text = "email id already
exists";
}
con.Close();
}
}
protected void
TextBox2_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(TextBox2.Text))
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
SqlCommand cmd = new
SqlCommand("select
MNo from GenDetails where Mno=@Mno", con);
cmd.Parameters.AddWithValue("@MNo",
TextBox2.Text);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
Label2.Text = "Mobile No already
exists";
}
con.Close();
}
}
}