I have this property in my ViewModel class:
public bool AreSimilarEntitiesChecked { get; set; }
In my controller I set its value 'true' and return the View with the model:
model.AreSimilarEntitiesChecked = true;
return View(model).WithWarning("Check the similar mentors before saving!");
On my View there is a form where I placed a hidden filed of this property:
@Html.HiddenFor(m => m.AreSimilarEntitiesChecked)
After the View returned with the model that contains the AreSimilarEntitiesChecked its value remains False desipte the fact I set the True valuse in the controller.
I don't know what could be wrong with it.
Generated HTML:
<input name="AreSimilarEntitiesChecked" id="AreSimilarEntitiesChecked"
type="hidden" value="False" data-val-required="The AreSimilarEntitiesChecked
field is required." data-val="true">
value="False"
so it's not being set totrue
. There is something else in your code preventing it being set, or is re-setting it. – Toormodel.AreSimilarEntitiesChecked = true;
in the GET or POST method? – Toor