What is the short way of writing this validation Error code?
I am using error validation on my winform and if there is a nice and short
way of writing this code please share with me. Thanks.
if (string.IsNullOrEmpty(txtSrcUserID.Text))
{
errorProvider1.SetError(txtSrcUserID, "Please enter Source
User_ID");
return;
}
else if (string.IsNullOrEmpty(txtSrcUserPassword.Text))
{
errorProvider1.SetError(txtSrcUserPassword, "Please enter
Source Password");
return;
}
else if (string.IsNullOrEmpty(txtSrcUserDatabase.Text))
{
errorProvider1.SetError(txtSrcUserDatabase, "Please enter
Source Database");
return;
}
else if (string.IsNullOrEmpty(txtTrgUserID.Text))
{
errorProvider1.SetError(txtTrgUserID, "Please enter Target
User_ID");
return;
}
else if (string.IsNullOrEmpty(txtDesPassword.Text))
{
errorProvider1.SetError(txtDesPassword, "Please enter
Target Password");
return;
}
No comments:
Post a Comment