<%=Html.RadioButton("BookType", "1") %> C#
<%=Html.RadioButton("BookType", "2") %> VB
以上代码生成以下代码
<input id="BookType" name="BookType" type="radio" value="1" >C#
<input id="BookType" name="BookType" type="radio" value="2" >VB
我需要相同名称但不同的ID
我想输出
*
<input id="rdoCSharp" name="BookType" type="radio" value="1" >C#
<input id="rdoVb" name="BookType" type="radio" value="2" >VB
*
答案 0 :(得分:35)
您可以使用overload of the RadioButton method传递要应用的属性来覆盖默认值:
<%=Html.RadioButton("BookType", "1", new { id = "yourId" }) %> C#
答案 1 :(得分:9)
<%= Html.RadioButton("BookType", "1", new { id = "rdoCSharp" }) %> C#
<%= Html.RadioButton("BookType", "2", new { id = "rdoVb" }) %> VB
答案 2 :(得分:5)
使用:
<%=Html.RadioButton("BookType", "1",new{@id="BookType1"}) %> C#
<%=Html.RadioButton("BookType", "2",new{@id="BookType2"}) %> VB