加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 将@ Html.RadioButtonFor设置为默认选中

发布时间:2020-12-16 06:59:54 所属栏目:asp.Net 来源:网络整理
导读:我无法将默认单选按钮设置为“已选中”! 我正在使用@ Html.RadioButtonFor: div id="private-user" @Html.RadioButtonFor(m = m.UserType,"type1",new { @class="type-radio",**@Checked="checked"** }) 1/divdiv id="proff-user" @Html.RadioButtonFor(m
我无法将默认单选按钮设置为“已选中”!
我正在使用@ Html.RadioButtonFor:

<div id="private-user">
    @Html.RadioButtonFor(m => m.UserType,"type1",new { @class="type-radio",**@Checked="checked"** }) 1
</div>
<div id="proff-user">
    @Html.RadioButtonFor(m => m.UserType,"type2",new { @class="type-radio" }) 2
</div>

是否可以使用@ Html.RadioButtonFor设置单选按钮?

谢谢

解决方法

看看这里 RadioButtonFor in ASP.NET MVC 2或列表 Has anyone implement RadioButtonListFor<T> for ASP.NET MVC?

如果您使用的是Enum,请参阅此答案pass enum to html.radiobuttonfor MVC3

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读