Note that there are some explanatory texts on larger screens.

plurals
  1. POselected check box in to controller
    text
    copied!<p>i have several check boxes in my view page..</p> <pre><code>&lt;div id ="rightPanelviewList"&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsChnView, new { id = "CHN"}) CHN &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsCMBView, new { id = "CMB"}) CMB &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsGermanyView, new { id = "Germany"}) Germany &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsHYDView, new { id = "HYD"}) HYD &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsSBUManagedServicesView, new { id = "SBUManagedServices"}) SBU: Managed Services &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsSBUSolutionsView, new { id = "SBUSolutions"}) SBU: Solutions &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsUSFSCView, new { id = "USFSC"}) US FSC &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsUSFTBView, new { id = "USFT"}) US FT &lt;/div&gt; &lt;div class ="divCheck"&gt; @Html.CheckBoxFor(model =&gt; model.IsUSWindsorView, new { id = "USWindsor"}) US Windsor &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Using json i tried to get the selected check boxes id's and here is my logic</p> <pre><code>$("#AllDimention").click( function() { if ($("#AllDimention").is(':checked')) { $("#CHN").prop('checked', true); $("#CMB").prop('checked', true); $("#HYD").prop('checked', true); $("#Germany").prop('checked', true); } var ViewNames = new Array(); var dict = []; // create an empty array $('#rightPanelviewList input[type=checkbox]').each(function() { var id = $(this).attr('id') dict.push({ key: id, value: $(this).attr('checked') }); alert(JSON.stringify(dict)) }); $.ajax({ url: '@Url.Action("Manage", "Admin")', type: 'POST', datatype: "json", traditional: true, data: { 'ViewNames': JSON.stringify(dict) }, success: function(result) { alert(JSON.stringify(result)); } }); }); </code></pre> <p>when redirect to view i'm getting error..</p> <p>"string is null"</p> <p>this is the model i tried to get</p> <pre><code>[HttpPost] public ActionResult Manage(ListBoxViewModel model, string ViewNames) { if (model.User != null) { } </code></pre> <p>can you please help me on this issue or give other alternatives for this issue. </p>
 

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