How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default

前端 未结 14 2033
一向
一向 2021-02-06 21:20

How can i Set RadioButtonFor() as Checked By Default

<%=Html.RadioButtonFor(m => m.Gender,\"Male\")%>

there is way out for (Html.Radio

14条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-06 21:57

    It's not too pretty, but if you have to implement only very few radio buttons for the entire site, something like this might also be an option:

    <%=Html.RadioButtonFor(m => m.Gender,"Male",Model.Gender=="Male" ? new { @checked = "checked" } : null)%>

提交回复
热议问题