1 2 3 4 5 6 7 8 | public class SalesFilterViewModel { public int CompanyId { get ; set ; } // will be required, even there's no Required attribute public int ? BranchId { get ; set ; } // will not be required public DateTime? StartingDate { get ; set ; } // nullable, will not be required public DateTime? EndDate { get ; set ; } // nullable, will not be required } |
1 2 3 4 5 6 7 8 9 10 11 12 | // A true-false type of polling public class Poll { public string QuestionId { get ; set ; } // When a default value of false(when you don't make the bool nullable, // it will default to false on page load) doesn't make sense, // but an answer(either true or false) is still required, make the // property nullable and add a Required attribute. [Required] public bool ? YourAnswer { get ; set ; } } |
No comments:
Post a Comment