Hi,
i'm making a regitration form. In that i need to validate the email taken from user. for thgat i've written a class in .cs file
public bool ValidateEmailAddress(String txt)
{
// Confirm there is text in the control.
bool abc = false;
if (txt.Trim().Length != 0)
{
// Confirm that there is a "." and an "@" in the e-mail address.
if (txt.IndexOf(".") == -1 || txt.IndexOf("@") == -1)
{
abc= false;
}
else
{
abc= true;
}
}
return abc;
}
Now i need to implement the method whle taking the data from user. can anyone pls guide
Thanks
SqlCommand cmd_insertuserDetail = new SqlCommand ("Insert into fwm_user (last_name, first_name, birth_date, address, city, postal_code, country, email, telephone, occupation, company)" +
" values (@last_name, @first_name, @birth_date, @address, @city, @postal_code, @country, @email, @telephone, @occupation, @company)", conn1);
cmd_insertuserDetail.Parameters.Add(new SqlParameter("@last_name", txtLName.Text));
.......
//cmd_insertuserDetail.Parameters.Add(new SqlParameter("@email", txtEmail.Text));
if (ValidateEmailAddress(txtEmail.Text)) ????????????
{
cmd_insertuserDetail.Parameters.Add(new SqlParameter("@email", txtEmail.Text));
}
else
{
MessageBox.Show("Enter valid Email ID", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
cmd_insertuserDetail.Parameters.Add(new SqlParameter("@telephone", txtTelephone.Text));
.....