标签:
当对CheckBox使用ValidationAttribute验证时,系统没有针对bool做True的验证。需要自己写一个。代码如下:
public class MustBeTrueAttribute : ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value is bool && (bool)value == true) return ValidationResult.Success; return new ValidationResult(FormatErrorMessage(validationContext.DisplayName)); } }
windows8 使用ValidationAttribute对CheckBox验证必须
标签:
原文地址:http://www.cnblogs.com/bent/p/4547008.html