MVC Radiobutton group

In order to group a series of radiobutton and allow only one control of the group to be selectable we’ll have to set the same value for the “name” attribute on all controls of the group. In Vb.Net

Code Snippet
<div id="group1">
    @Html.RadioButton("group1", False, New With {.class = "radioClass"})
    @Html.RadioButton("group1", False, New With {.class = "radioClass"})
    @Html.RadioButton("group1", False, New With {.class = "radioClass"})
</div>
<div id="group2">
    @Html.RadioButton("group2", False, New With {.class = "radioClass"})    
    @Html.RadioButton("group2", False, New With {.class = "radioClass"})
    @Html.RadioButton("group2", False, New With {.class = "radioClass"})
</div>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s