In an ASP.NET MVC application, I have two radio buttons. Depending on a boolean value in the model, How do I enable or disable the radio buttons? (The values of the radio buttons are also part of the model)
My radio buttons currently look like this -
@Html.RadioButtonFor(m => m.WantIt, "false")
@Html.RadioButtonFor(m => m.WantIt, "true")
In the model, I have a property called model.Alive. If model.Alive is true I want to enable the radio buttons, else if model.Alive is false, I want to disable the radio buttons.
Thanks!
if (Model.Alive) { setcss enabled or @Html.RadioButonFor//Display radio buttons }Just check the model state if true set properties or don't create the radio buttons at all - Nate-Wilkins