I want to show a watermark on the textbox control in window application. [Resolved]

Posted by Harikrishna.veluru under C# on 12/20/2011 | Points: 10 | Views : 3146 | Status : [Member] | Replies : 2
Hi,

I want to show a watermark on the textbox control in window application.please do the needful.

Regards,
Hari.

best,
hari



Responses

Posted by: Sudheep.grandhe on: 12/20/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
private void btn_submit_Click(object sender, EventArgs e)
{
if (txt_customername.Text == string.Empty)
{
MessageBox.Show("please enter the customer name:");
txt_customername.Focus();
}
else
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
SqlCommand cmd = new SqlCommand("insert into tbl_customer(custname,custaddress,custcity,custstate,custstdcode,custphoneno,custmobileno)values(@custname,@custaddress,@custcity,@custstate,@custstdcode,@custphoneno,@custmobileno)", con);
cmd.Parameters.AddWithValue("@custname", txt_customername.Text);
cmd.Parameters.AddWithValue("@custaddress", txt_address.Text);
cmd.Parameters.AddWithValue("@custcity", txt_customercity.Text);
cmd.Parameters.AddWithValue("@custstate", txt_customerstate.Text);
cmd.Parameters.AddWithValue("@custstdcode", txt_stdcode.Text);
cmd.Parameters.AddWithValue("@custphoneno", txt_phoneno.Text);
//if (txt_mobileno.Text = "" || txt_mobileno.Text.Trim() == "" || txt_mobileno.Text == null)
// txt_mobileno.Text = "0";
cmd.Parameters.AddWithValue("@custmobileno", txt_mobileno.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("customer added successfully..");
con.Close();
try
{
MessageBox.Show(txt_customername.Text.Trim()
+ " " + txt_address.Text.Trim()
+ " " + txt_customercity.Text.Trim()
+ " " + txt_customerstate.Text.Trim()
+ " " + txt_stdcode.Text.Trim()
+ " " + txt_phoneno.Text.Trim()
+ " " + txt_mobileno.Text.Trim()
+ " " + textBox5.Text.Trim()
+ " " + textBox8.Text.Trim());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
txt_customername.Text = "";
txt_address.Text = "";
txt_customercity.Text = "";
txt_customerstate.Text = "";
txt_stdcode.Text = "";
txt_phoneno.Text = "";
txt_mobileno.Text = "";
}
}
private void AddCustomer_Load(object sender, EventArgs e)
{
try
{
txt_customername.SetWatermark("customername");
txt_address.SetWatermark("address");
txt_customercity.SetWatermark("customercity");
txt_customerstate.SetWatermark("customerstate");
txt_stdcode.SetWatermark("stdcode");
txt_phoneno.SetWatermark("phoneno");
txt_mobileno.SetWatermark("mobileno");
textBox5.SetWatermark("+91-");
textBox8.SetWatermark("+91-");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

}
 Download source file

Best,
Sudheep.

Harikrishna.veluru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/20/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

refer http://www.codeproject.com/KB/miscctrl/WaterMark.aspx

Regards,
Sunil

Harikrishna.veluru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response