1

我会问一些其他地方。感谢所有回复!

4

1 回答 1

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; 
    }
}
于 2013-09-12T08:43:04.407 回答