hi dear,
here use one function.
public bool IsValid()
{
bool flag = true;
if (textBox1.Text.Trim() == "")
{
ErrPro.SetError(textBox1, "textBox1 value is required.");
flag = false;
}
else
{
ErrPro.SetError(textBox1, "");
}
if (textBox2.Text.Trim() == "")
{
ErrPro.SetError(textBox2, "textBox2 value is required.");
flag = false;
}
else
{
ErrPro.SetError(textBox2, "");
}
if (textBox3.Text.Trim() == "")
{
ErrPro.SetError(textBox3, "textBox3 value is required.");
flag = false;
}
else
{
ErrPro.SetError(textBox3, "");
}
if (textBox4.Text.Trim() == "")
{
ErrPro.SetError(textBox4, "textBox4 value is required.");
flag = false;
}
else
{
ErrPro.SetError(textBox4, "");
}
if (textBox5.Text.Trim() == "")
{
ErrPro.SetError(textBox5, "textBox5 value is required.");
flag = false;
}
else
{
ErrPro.SetError(textBox5, "");
}
if (textBox6.SelectedIndex == 0)
{
ErrPro.SetError(textBox6, "textBox6 value is required.");
flag = false;
}
else
{
ErrPro.SetError(textBox6, "");
}
return flag;
}
//-------------------------------------
private void SearchButton_Click(object sender, EventArgs e)
{
if (!IsValid() == true)
{
return;
}
else
{
}
}