I have a list of checkboxes and I want to run a function when they are clicked.
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.RequiresSetup)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.CheckBox("RequiresSetup", item.RequiresSetup)
</td>
</tr>
}
</table>
So far I am using @Html.CheckBox(String, bool)
, but this is not enough. After checking the InputExtensions.CheckBox Method Documentation I also do not see a way out of it.
I want to detect when a user checks or unchecks a certain checkbox, so I can call a function that immediatly saves the change in the database.
After my research I also believe I need something like this:
void Handle_Clicked(Object sender, EventArgs e) {
//save to DB
}
But I have no idea on how to tell CheckBox "i" to that that funcion accordingly.
How do I proceed?