lundi 10 juillet 2017

ASP.Net MVC6 Checkbox value to controller

I am trying to create a checkbox on its own and when its clicked it will send a true or false value back to the controller based on the result it will add the userId or remove it and return results based on this. I am not using a model and I would like to not have a button just once its clicked to submit the request.

So far I have:

@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
   <label>View All Tickets @Html.CheckBox("chkAllTickets")</label>
}

And I just wanna send back something like public ActionResult Index(bool Checked) and checked will either hold true or false when clicked.

Do I need to use jQuery or is it simpler then that and I'm just missing something. Up until now I have done everything with ease and this is giving me a lot of trouble.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire