How do I set a checkbox in razor view?

后端 未结 10 2107
南笙
南笙 2020-12-05 17:01

I need to check a checkbox by default:

I tried all of these, nothing is checking my checkbox -

@Html.CheckBoxFor(m => m.AllowRating, new { @value          


        
10条回答
  •  北海茫月
    2020-12-05 17:54

    This works for me:

    
    

    If you really wants to use HTML Helpers:

    @Html.CheckBoxFor(m => m.AllowRating, new { @checked = Model.AllowRating})
    

提交回复
热议问题