Radio Buttons Converting Html into Html Helpers syntax
I have the following two radio buttons in my razor form which uses a ternary operator to either default to checked or not checked and is bound to my model. Also, I need the first radio button to be defaulted to checked.
I am moving over to the use of Html Helpers instead and wanted to do something like the following
@Html.RadioButtonFor(m => m.Details.EffectiveImmediately, new {@name = "user-activation"})
@Html.RadioButtonFor(m => m.Details.EffectiveInAWeek, new { @name = "user-activation" })
-The first problem is that I seem to have lost the ability to make the buttons mutally exclusive. I thought that adding in the name attribute would do it but didn't. I know that Html.RadioButton is mutually exclusive but Im not sure I can use it with the syntax I'm using here.
-The second problem is that I have lost the functionality of the ternary operator which checks or unchecks a button. I though the following would work since it seems to be all over the web but its not working for me
@Html.RadioButtonFor(m => m.Details.EffectiveImmediately, new { @checked = "checked" })
neither did
@Html.RadioButtonFor(m => m.Details.EffectiveImmediately, new { @checked = true })
or
@Html.RadioButtonFor(m => m.Details.EffectiveImmediately, true, new { @checked = "checked" })
Bookmarks