I have a model below:
public class Learning
{
public bool active { get; set; } = false;
}
in learning.cshtml
<div class="form-check form-switch form-check-primary">
<input type="checkbox" class="form-check-input" id="active" for-asp="active" tabindex="4" onclick="activeClick(this);" @(Model.active ? "checked" : "") />
</div>
and I try to update active value using javascript
<script>
function activeClick(cb) {
@Model.active = cb.checked;
}
</script>
and in controller
[HttpPost]
[Route("/User/Add_Update")]
public IActionResult Add_Update(Views.Learning learning)
{
bool active = learning.active; // THIS IS NOT WORKING, the active value keeps false
why the active value keeps false?, what I missed?