Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 mvc4 中使用 DataAnnotations 仅用于数字但大于 0 的有效值,请帮助。
谢谢。
您可以使用以下[Range]属性:
[Range]
[Range(1, int.MaxValue, ErrorMessage = "The value must be greater than 0")] public int Value { get; set; }