Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to check if all checkboxes in an editor template is checked
    primarykey
    data
    text
    <p>I have a form using an editor template showing a series of checkboxes pertaining to a child list inside the form model. On form submit I need to check if all the checkboxes are checked for all child items and if not display a modal dialog to make sure that the user purposely decided to leave some of the checkboxes unchecked. I know that I can use the JQuery dialog to show the modal dialog, but I have no idea how to see if all the checkboxes in the editor templates are checked. My code is similar to the following:</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;Test.Models.ModelList&gt;" %&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt; ShowPropReturn &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;h2&gt;ShowPropReturn&lt;/h2&gt; &lt;script src="&lt;%: Url.Content("~/Scripts/jquery.validate.min.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="&lt;%: Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;% using (Html.BeginForm()) { %&gt; &lt;%: Html.ValidationSummary(true) %&gt; &lt;fieldset&gt; &lt;legend&gt;ModelList&lt;/legend&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(model =&gt; model.MyProperty1) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%: Html.EditorFor(model =&gt; model.MyProperty1) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.MyProperty1) %&gt; &lt;/div&gt; &lt;div class="editor-label"&gt; &lt;%: Html.LabelFor(model =&gt; model.MyProperty2) %&gt; &lt;/div&gt; &lt;div class="editor-field"&gt; &lt;%: Html.EditorFor(model =&gt; model.MyProperty2) %&gt; &lt;%: Html.ValidationMessageFor(model =&gt; model.MyProperty2) %&gt; &lt;/div&gt; &lt;table&gt; &lt;%: Html.EditorFor(model =&gt; model.MyProperty3) %&gt; &lt;/table&gt; &lt;p&gt; &lt;input type="submit" value="Save" /&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;% } %&gt; &lt;div&gt; &lt;%: Html.ActionLink("Back to List", "Index") %&gt; &lt;/div&gt; &lt;/asp:Content&gt; </code></pre> <p>and for the editor template:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;Test.Models.ColumnList&gt;" %&gt; &lt;tr&gt; &lt;td&gt; &lt;%= Html.CheckBoxFor(x =&gt; x.value) %&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Any help would really be appreciated, thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload