asp.net mvc - Custom Required attribute - property required depending of parent model value -
i have model productmodel has: * bool isnew property * productdetailsmodel details property
public class productmodel { public bool isnew { get; set; } public productdetails details { get; set; } } public class productdetails { public string code { get; set; } public string type { get; set; } public string description { get; set; } public int number { get; set; } }
productdetails has other properties eg. code, type, description, number
i make description , number property of productdetailsmodel required if isnew of productmodel set true.
how it?
btw have more properties of custom types within productmodel , can't move properties single productmodel.
i found answer here asp.net mvc conditional validation
it seems easiest way implement validation in product model.
Comments
Post a Comment