Bonjour à tous !
J'aimerai avec razor avoir une checkbox cochée par défaut dans mon formulaire.
Comment faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 <div class="form-group"> @Html.LabelFor(model => model.actif, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> <div class="checkbox"> @Html.EditorFor(model => model.actif) @Html.ValidationMessageFor(model => model.actif, "", new { @class = "text-danger" }) </div> </div> </div>
j'ai essayé plusieurs chose telle que :
mais rien ne fonctionne
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 @Html.EditorFor(model => model.actif, new { @checked="checked" }) @Html.EditorFor(model => model.actif, new { @checked="true" }) @Html.EditorFor(model => model.actif, true)![]()
Partager