Click here to Skip to main content
16,016,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Radio Group But both are pass FALSE Only.



What I have tried:

HTML
@Html.RadioButtonFor(model => model.NpdIndicator, new { @class = "radio-inline", @checked = "checked", id = "A" }, "Indicator")
                                                @Html.Label("Active")
                                                @Html.RadioButtonFor(model => model.NpdIndicator, new { @class = "radio-inline", @checked = "checked", id = "B" }, "Indicator")
                                                @Html.Label("InActive")
Posted
Updated 11-Nov-16 2:37am
v2

1 solution

The second parameter to the RadioButtonFor[^] method is the value of the selected radio button.

You are passing an anonymous object, which looks more like the HTML attributes for the radio button.

Change your code to use the method properly. For example, assuming the NdpIndicator property is a bool:
@Html.RadioButtonFor(model => model.NdpIndicator, true, new { @class = "radio-inline", id = "A" })
@Html.Label("A", "Active")
@Html.RadioButtonFor(model => model.NdpIndicator, false, new { @class = "radio-inline", id = "B" })
@Html.Label("B", "Inactive")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900