i am trying to create strongly type checkbox but this not working properly and
checkbox not show is checked but flag is true in model
please suggest me
code:-
@Html.CheckBoxFor(model => model.Active, new { @checked =true})
i am trying to create strongly type checkbox but this not working properly and
checkbox not show is checked but flag is true in model
please suggest me
code:-
@Html.CheckBoxFor(model => model.Active, new { @checked =true})
Use a EditorFor
@Html.EditorFor(model => model.Active, new { Value = model.Active})
or
@Html.EditorFor(model => model.Active)
As other users have said: Set the value of Active on the model Controller-side before you get to the View and also, Active must be a boolean type. (this is as per the solution @Esko suggested)