.NET에서 MVC 3의 boolean
속성에 대해 True
값을 요구하는 방법은 무엇입니까? 이다 내가 어디, 나는 여기에 MVC .net 등록 정보의 필수 속성에 대한 부울 값 True
<Required()> _
<DisplayName("Agreement Accepted")> _
Public Property AcceptAgreement As Boolean
링크가이 클래스를
Public Class BooleanMustBeTrueAttribute Inherits ValidationAttribute
Public Overrides Function IsValid(ByVal propertyValue As Object) As Boolean
Return propertyValue IsNot Nothing AndAlso TypeOf propertyValue Is Boolean AndAlso CBool(propertyValue)
End Function
End Class
추가 추가 언젠가
죽는 경우 수정입니다 유효하지의 othewise True
을 할 가치가 필요합니다 속성
<Required()> _
<DisplayName("Agreement Accepted")> _
<BooleanMustBeTrue(ErrorMessage:="You must agree to the terms and conditions")> _
Public Property AcceptAgreement As Boolean
나는 이것이 오래된 것을 알고있다. 그러나 당신이 당신의 해답을 해답으로 추가한다면, 나는 upvote 할 것이다 :) – JMK