I have a property on one of my objects that is a nullable boolean, I want my logic to have true represent Yes, false to be No and null to be N/A. Now because I am going to h
using Canvas example above I built a customization model and view so you can control the values via a model and edit them in code, bools aren't always a yes/no/(n/a) so Here's how it looks in MVC5.
using a generic model for the nullable bool
public class Customisable_NullableRadioBool
{
public bool? Result { get; set; }
public string TrueLabel { get; set; }
public string FalseLabel { get; set; }
public string NullLabel { get; set; }
public string AttributeTitle { get; set; }
}
Here's the CSHTML to be stored in: ~/Views/Shared/EditorTemplates/Customisable_NullableRadioBool.cshtml
@model Customisable_NullableRadioBool
@Model.AttributeTitle
And then you can reference the generic class and the editor template through the rest of your project and render the editor template like this.
@Html.EditorFor(m => m.YourCustomisable_NullableBool, "Customisable_NullableRadioBool")
And the rendered output examples