我会问别的地方。谢谢所有回复!
答案 0 :(得分:2)
可能是这个
public class ControlValidationInfo
{
public Control Control { get; set; }
public string EmptyTextErrorMessage { get; set; }
}
ControlValidationInfo[] infos = new []{ new ControlValidationInfo{ Control = txtSrcUserID, EmptyTextErrorMessage = "Please enter Source User_ID"}}; // add all in this array
foreach(var info in infos)
{
if(String.IsNullOrEmpty(info.Control.Text))
{
errorProvider1.SetError(info.Control , info.EmptyTextErrorMessage);
return;
}
}