I call three functions in my code where I want to check some of my fields. When I try to work with the code below. It only checks the first value until it gets a false result.
I need something like this if the fisrt function returns true, then it should also call the next function and so on. What can be used instead of Or Operator for this.
if (IsFieldEmpty(ref txtFactoryName, true, "Required") ||
IsFieldEmpty(ref txtShortName, true, "Required") ||
IsFieldEmpty(ref cboGodown, true, "Required"))
{ }
EDIT
public bool IsFieldEmpty(ref TextBox txtControl, Boolean SetErrorProvider,string msgToShowOnError)
{
ErrorProvider EP = new ErrorProvider();
if (txtControl.Text == string.Empty)
{
EP.SetError(txtControl, msgToShowOnError);
return true;
}
else
{
EP.Clear();
return false;
}
}
Comment, this method makes excellent use of the ref variable as one of the parameters.
I am checking for confirmation in Submit's event winform.
source
share