In first,I have to create some radio buttons in a mvc3 partial view.
When I’m on the screen I need to select only one radio button and retrieved a specific value.
How can I do this (with JS or C# for example) ?
<div id="UserDeleteInfosField">
<p>
@Html.RadioButton("HasUserLeave", new { id = "rb1" })
@UserAccountResources.UserLeave
@Html.HiddenFor(x => x.UserLeave)
</p>
<br />
<p>
@Html.RadioButton("HasUserTransfer", new { id = "rb2" })
@UserAccountResources.UserTransfer
@Html.HiddenFor(x => x.UserTransfer)
</p>
<br />
<p>
@Html.RadioButton("HasUserDetachment", new { id = "rb3" })
@UserAccountResources.UserDetachment
@Html.HiddenFor(x => x.UserDetachment)
</p>
<br />
<p>
@Html.RadioButton("HasUserRetirement", new { id = "rb4" })
@UserAccountResources.UserRetirement
@Html.HiddenFor(x => x.UserRetirement)
</p>
<br />
<p>
@Html.RadioButton("HasUserStatus", new { id = "rb5" })
@UserAccountResources.UserStatus
@Html.HiddenFor(x => x.UserStatus)
</p>
</div>
Thanks in advance !
Ars_n
Look at example to understand how radio buttons are grouped: example
You need same
nameattribute, like here:Your example:
Only checked value you will receive in controller action on post.