Make a checkbox checked or unchecked based on the value?

前端 未结 8 1336
星月不相逢
星月不相逢 2020-12-29 23:02

How can we make a checkbox checked or unchecked programatically based on the value? That is to say, for a particular user if the value is true, the checkbox should be checke

8条回答
  •  忘掉有多难
    2020-12-29 23:23

    if(condition = true)
    {
    @Html.CheckBoxFor(x => x.Test, new { @checked = "checked" })
    }
    else
    {
    @Html.CheckBoxFor(x => x.Test)
    }
    

    Hope this helps :)

提交回复
热议问题