using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class userreg : System.Web.UI.Page
{
SqlConnection con;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (chk().ToString() == "1")
{
con = new SqlConnection(ConfigurationSettings.AppSettings["con"].ToString());
SqlCommand reg = new SqlCommand("insert into userreg(email,add,fname,lname,age,gender,country,mob_mod,mob_no)values('" + TextBox5.Text + "','" + TextBox6.Text + "','" + TextBox7.Text + "','" + TextBox10.Text + "','" + RadioButtonList1.SelectedItem.ToString() + "','" + DropDownList4.SelectedItem.ToString() + "','" + DropDownList5.SelectedItem.ToString() + "','" + TextBox9.Text + "')", con);
SqlCommand log = new SqlCommand("insert into Login(uname,pass,role)values('" + TextBox2.Text + "','" + TextBox3.Text + "','user')", con);
con.Open();
reg.ExecuteNonQuery();
log.ExecuteNonQuery();
Label2.Text = "Registration Complet";
con.Close();
}
else
{
Label1.Text = "User Name Not avilable";
}
}
public string chk()
{
string flag;
con = new SqlConnection(ConfigurationSettings.AppSettings["con"].ToString());
SqlDataAdapter sda=new SqlDataAdapter("select * from Login where uname='"+ TextBox2.Text +"'",con);
DataSet ds=new DataSet();
sda.Fill(ds);
if(ds.Tables[0].Rows.Count>0)
{
flag="0";
}
else
{
flag="1";
}
return flag;
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
if(chk().ToString()=="1")
{
Label1.Text="User name available";
}
else
{
Label1.Text = "plese use different user name";
}
}
}
Pls replay this solution