I am trying to find the right Razor syntax for mutually exclusive switches that reflect the value of a boolean property in my model. My model has the following:
public bool IsFemale{ get; set; }
I would like to show this with two switches: “Male” and the other “Female”, but everything I have tried so far has not reflected the actual value of the IsFemale property on the model. I currently have this:
@Html.RadioButtonFor(model => model.IsFemale, !Model.IsFemale) Male @Html.RadioButtonFor(model => model.IsFemale, Model.IsFemale) Female
It is like storing a value correctly if I change and update, but don’t check the correct value as noted. I'm sure this is something stupid, but I'm stuck.
asp.net-mvc razor asp.net-mvc-4
Aj. May 09 '12 at 14:40 2012-05-09 14:40
source share