Skip to main content
 首页 » 编程设计

c#之将 <input> 更改为 @Html.RadioButtonFor

2024年02月05日9shanyou

很简单的问题,但很难找到答案。我如何转换

<input type="radio" id="radAnswer" name="answer" value="@answer" /> 

到

@Html.RadioButtonFor(/*some sort of code in here*/) 

提前致谢!

请您参考如下方法:

有点像

  @Html.RadioButtonFor(x => x.answer, your value, new { @id= "radAnswer" , @class="any"}) 

对于新的属性定义,比如选中的单选按钮

 new { Checked = "checked"}