How to handle Booleans/CheckBoxes in ASP.NET MVC 2 with DataAnnotations?

后端 未结 12 1179
慢半拍i
慢半拍i 2020-12-04 10:09

I\'ve got a view model like this:

public class SignUpViewModel
{
    [Required(ErrorMessage = \"Bitte lesen und akzeptieren Sie die AGB.\")]
    [DisplayName         


        
12条回答
  •  情深已故
    2020-12-04 10:32

    The proper way to do this is to check the type!

    [Range(typeof(bool), "true", "true", ErrorMessage = "You must or else!")]
    public bool AgreesWithTerms { get; set; }
    

提交回复
热议问题