when clicking on the checkbox, form is submitted using jquery, but Checkbox always return null.
I have the following Razor Code:
@using (Html.BeginForm("Index", "HumanResource", new { type = ViewBag.CurrentType }, FormMethod.Post, new { id = "form1" }))
{
<label class="custom-control custom-checkbox" for="Filter">
@Html.CheckBox("Filter", new { @class = "custom-control-input" })
<span class="custom-control-indicator"></span>
Choose
</label>
}
//Scipts
<script>
$('#form1 :checkbox').change(function() {
$("#form1").submit();
});
</script>
Controler
public async Task<ActionResult> Index(FormCollection fc,int? Filter)
{
//leftFilter is always null
}
Aucun commentaire:
Enregistrer un commentaire