Reputation: 3615
<%=Html.RadioButton("BookType", "1") %> C#
<%=Html.RadioButton("BookType", "2") %> VB
Above code generates Below code
<input id="BookType" name="BookType" type="radio" value="1" >C#
<input id="BookType" name="BookType" type="radio" value="2" >VB
I need same name but different ids
I want output like
*
<input id="rdoCSharp" name="BookType" type="radio" value="1" >C#
<input id="rdoVb" name="BookType" type="radio" value="2" >VB
*
Upvotes: 29
Views: 55273
Reputation: 41757
You can override the defaults by passing the attributes you wish to apply using an overload of the RadioButton method:
<%=Html.RadioButton("BookType", "1", new { id = "yourId" }) %> C#
Upvotes: 38
Reputation: 1038750
<%= Html.RadioButton("BookType", "1", new { id = "rdoCSharp" }) %> C#
<%= Html.RadioButton("BookType", "2", new { id = "rdoVb" }) %> VB
Upvotes: 9
Reputation: 10374
Use:
<%=Html.RadioButton("BookType", "1",new{@id="BookType1"}) %> C#
<%=Html.RadioButton("BookType", "2",new{@id="BookType2"}) %> VB
Upvotes: 5