How to submit upon a check or uncheck of checkbox in form?
Posted
by user281180
on Stack Overflow
See other posts from Stack Overflow
or by user281180
Published on 2010-05-18T06:50:52Z
Indexed on
2010/05/18
7:01 UTC
Read the original article
Hit count: 171
asp.net-mvc
I have the following in my form
<td><input id="Notifications_0__IssueCreate" name="Notifications[0].IssueCreate" type="checkbox" value="true" /><input name="Notifications[0].IssueCreate" type="hidden" value="false" /></td>
<td><input id="Notifications_0__AllChanges" name="Notifications[0].AllChanges" type="checkbox" value="true" /><input name="Notifications[0].AllChanges" type="hidden" value="false" /></td>
In the partial view it`s wrriten as :
<%int count = 0; %>
<%foreach (var item in Model.List)
{%>
<tr>
<td><%=Html.CheckBox("Notifications[" + (count) + "].IssueCreate", item.IssueCreate)%></td>
<td><%=Html.CheckBox("Notifications[" + (count++) + "].AllChanges", item.AllChanges)%></td>
</tr>
<%}
%>
I want to submit to the controller upon each and every click on any of the checkbox. i.e, if user checks the checkbox, it sends the name of the checkbox and if selected or not to the controller, using ajax post.
How can I do that?
© Stack Overflow or respective owner