Need a placeholder to show a text of the textbox which disappears when I click or enter text in the text box
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;
public partial class SIGNUPaspx : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Admin\Documents\Visual Studio 2010\WebSites\my website\App_Data\GYMDatabase.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from Client_Data Where C_Email='" + TextBox6.Text + "'";
cmd.Connection = con;
SqlDataReader rd = cmd.ExecuteReader();
rd.Read();
if (rd.HasRows)
{
Label1.Text = "Email Already Exist";
}
else
{
SqlConnection con1 = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Admin\Documents\Visual Studio 2010\WebSites\my website\App_Data\GYMDatabase.mdf;Integrated Security=True;User Instance=True");
con1.Open();
String str = "INSERT INTO Client_Data(C_FName,C_LName,C_Address,C_Gender,C_Email,C_Password,C_MobileNo,C_RegistrationCode) VALUES ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox8.Text + "','" + RadioButtonList1.Text + "','" + TextBox6.Text + "','" + TextBox4.Text + "','" + TextBox7.Text + "','" + TextBox5.Text + "')";
SqlCommand cm = new SqlCommand(str, con1);
String str1 = "INSERT INTO PaymentTable(C_Email) VALUES ('" + TextBox6.Text + "')";
SqlCommand cmp = new SqlCommand(str1, con1);
cm.ExecuteNonQuery();
cmp.ExecuteNonQuery();
con.Close();
Label1.Visible = true;
Response.AddHeader("REFRESH", "3;URL=LOGIN.aspx");
}
rd.Close();
con.Close();
}
private void TextBox1_Enter(object sender, EventArgs e)
{
if (TextBox1.Text == "First Name")
{
TextBox1.Text = "";
}
}
private void TextBox1_Leave(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{
TextBox1.Text = "First Name";
TextBox1.ForeColor = System.Drawing.Color.LightGray;
}
}
}