我有一个名为 CustomerType 的下拉列表,其中包含以下值
Id Name
1 Student
2 Non-Employed
3 Employed
4 SelfEmployed
我的财产中还有一处viewmodel
public string CompanyAddress{ get; set; }
如果下拉列表具有值,我的目标是使 CompanyAddress 成为必需3 or 4
我尝试了以下但得到错误Cannon have duplicate RequiredIf
[RequiredIf("customerTypeID", 3, ErrorMessage = "Please enter company address")]
[RequiredIf("customerTypeID", 4, ErrorMessage = "Please enter company address")]
public string CompanyAddress { get; set; }