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!
Best Answer
You could pass the values directly as htmlAttributes like so:
If you need to check for model.Alive then you could do something like this:
Hope that helps