Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在研究 asp.net MVC 4。但我对如何为 Radio-buttons 表指定组名称感到困惑。所以每组单选按钮都可以在特定时间检查按钮。我正在使用Html.RadioButtonfor.
Html.RadioButtonfor
“组名”由name字段的属性决定:所有具有相同name属性值的单选按钮都在同一个“组”中。因此,出于使用目的Html.RadioButtonFor,您只需为组中的每个单选指定相同的属性,并为按钮设置一个唯一值,即:
name
Html.RadioButtonFor
@Html.RadioButtonFor(m => m.AnimalType, "Cat") @Html.RadioButtonFor(m => m.AnimalType, "Dog") @Html.RadioButtonFor(m => m.AnimalType, "Chicken")