I have textbox validation for not empty and wrong value for edit mode, when i entered wrong data in textbox,i cannot click cancel button, Validation occurs.
this is for windows form application, i did validation.
if (dataLogic.IsEmpty(txtSubCourseName.Text))
{
dataLogic.DisplayEmptyMsg();
e.Cancel = true;
return;
}
if (tag != "New")
{
DataTable dt = new DataTable();
sda = new SqlDataAdapter("SELECT * FROM tblSubCourse WHERE SubCourseName='" + txtSubCourseName.Text + "'", con);
con.Open();
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
txtSubCourseName.Text = dt.Rows[0]["SubCourseName"] + "";
}
else
{
dataLogic.EmptyMsg();
e.Cancel = true;
return;
}
}
i expect to not validate when i click cancel button and escape button, even entered data is wrong.