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">