Reputation: 51104
I have to make a Yes/No answer mandatory. The project owner wants a 'checkbox' which would involve some ugly with a tri-state checkbox, or two radio buttons. the latter seems the neatest, but I have no idea how to make it so that only one of the checkboxes must be checked. My only other idea is to stuff the checkboxes and use a dropdown.
Upvotes: 0
Views: 730
Reputation: 5407
Use
[Required]
public bool? YesNo { get; set; }
In the ViewModel and make sure it's initially null.
Bool is by default false. By using nullable bool?, you set it's initial state to null.
Upvotes: 2