我正在尝试处理 asp MVC 5 中的单选按钮 ID
我正在这样工作
示例模型
class A
{
public bool? radio { get; set; }
}
在剃刀视图中
@Html.RadioButtonFor(x => x.NeutroBT, Model.NeutroBT, new { @id = "True"})
@Html.RadioButtonFor(x => x.NeutroBT, !Model.NeutroBT, new { @id = "False})
它不会引起问题,但我正在编辑器模板中工作,我希望它已经生成id,以某种方式访问,就像@Html.IdFor(x => x.NeutroBT, true)从@Html.IdFor(x => x.NeutroBT, false)其他视图一样,只是防止将来发生变化
有这样的可能吗?我花了很多时间搜索,但没有得到类似的东西
如果不可能,最好的处理方法是什么?
谢谢!