Pass values of checkBox to controller action in asp.net mvc4
I want to test if the checkbox is checked or not from my acion methon,
what i need is to pass checkbox value from view to controller
this is my view
@using (Html.BeginForm("Index", "Graphe"))
{
<table style="width: 100%;" border="1">
<tbody>
<tr>
<td>Responsable:</td>
<td><select id="Responsables" name="responsables"
><option>Selectionnez --</option></select></td>
<td><input id="responsable" name="checkResp" type="checkbox" />
</td>
</tr>
<tr> <td><input type="submit" value="Afficher"
id="ButtonSubmit"/></td>
<td><input class="button" id="ButtonReset" type="button"
value="Annuler" /></td>
</tr>
</tbody>
and i try that :
public ActionResult Index( string responsables, bool checkAct)
{
Highcharts chart = new Highcharts("chart");
if (responsables != null)
{
if (checkAct)
chart = Global();
else
chart = Resp(responsables);
}
else
chart = Global();
return View(chart);
}
, but i have this error :
Le dictionnaire de paramètres contient une entrée Null pour le paramètre «
checkAct » de type non Nullable « System.Boolean » pour la méthode «
System.Web.Mvc.ActionResult Index(System.String, System.String, Boolean) »
dans « Project.Controllers.GrapheController ». Un paramètre facultatif
doit être un type référence, un type Nullable ou être déclaré en tant que
paramètre facultatif. Nom du paramètre : parameters
Can you help me please !
No comments:
Post a Comment