Blankman
Blankman

Reputation: 267370

radio button helper with 2 buttons

I need to display 2 radio buttons horizontally, where the user can only have 1 selected at a time.

Html.Radiobutton doesn't seem to group items together.

how can this be achieved?

Upvotes: 0

Views: 289

Answers (2)

Pankaj
Pankaj

Reputation: 4503

It need same name like this

<input  type='radio' name='Rd1' value='true' />

<input  type='radio' name='Rd1'  value='false'/>

Upvotes: 1

JustinStolle
JustinStolle

Reputation: 4460

The radio buttons need to have the same name, but use a different value.

<%= Html.RadioButton("myRadioButton", "yes")%>
<%= Html.RadioButton("myRadioButton", "no")%>
<%= Html.RadioButton("myRadioButton", "neither")%>

Upvotes: 2

Related Questions