是否可以在ASP.NET MVC中调整其他人的必填字段?
所以当它成真时
[Required(ErrorMessageResourceName = "ThisFieldIsRequired", ErrorMessageResourceType = typeof(Resource))]
[Display(Name = "IsPostAddressIsVisitingAddress", ResourceType = typeof(MyModelEntities.Properties.Resource))]
public bool IsPostAddressIsVisitingAddress { get; set; }
然后我们应该“开启”
[Required(ErrorMessageResourceName = "ThisFieldIsRequired", ErrorMessageResourceType = typeof(Resource))]
的
[Display(Name = "AddressLine1", ResourceType = typeof(MyModelEntities.Properties.Resource))]
public string PostAddressLine1 { get; set; }
谢谢!
答案 0 :(得分:0)
感谢Andrei V.和Christophano
Conditional validation on model in MVC
http://foolproof.codeplex.com/
所以我刚刚添加了对该DLL的引用,它工作正常!
[RequiredIfTrue("IsPostAddressIsVisitingAddress",(ErrorMessageResourceName = "ThisFieldIsRequired", ErrorMessageResourceType = typeof(Resource))]