Post checkboxes even when not selected

I am writing out a dynamic list of checkboxes.


            <div class="panel col-md-5">
                <span width="10"></span>
                @{
                    foreach (string key in Model.Filter.StatusFilters.Keys)
                    {
                        <label class="checkbox-inline" style="width: 30%">
                            @Html.EJ().CheckBoxFor(m => m.Filter.SelectedStatusFilters[key]).Value("false")
                            @string.Format("{0} ({1})", Model.Filter.StatusFilters[key].Name, Model.Filter.StatusFilters[key].Count)
                        </label>
                    }
                }
            </div>

The first time the page is loaded, I build my model and StatusFilters and create the SelectedStatusFilters dictionary.  When the user posts the data back, it's model binding that recreates the SelectedStatusFilters.  With the standard Html.CheckboxFor(), all checkboxes are posted back.

  1. Filter.SelectedStatusFilters[Website]:
    false
  2. Filter.SelectedStatusFilters[Denied]:
    false
  3. Filter.SelectedStatusFilters[Potential]:
    true
  4. Filter.SelectedStatusFilters[Potential]:
    false
  5. Filter.SelectedStatusFilters[Review]:
    false
  6. Filter.SelectedStatusFilters[Testing]:
    false
  7. Filter.SelectedStatusFilters[Active]:
    true
  8. Filter.SelectedStatusFilters[Active]:
    false
  9. Filter.SelectedStatusFilters[Selected]:
    false
  10. Filter.SelectedStatusFilters[Inactive]:
    false
  11. Filter.SelectedStatusFilters[Retired]:
    false
  12. Filter.SelectedStatusFilters[Dropped]:
    false
  13. Filter.SelectedStatusFilters[Deleted]:
    false
  14. Filter.SelectedStatusFilters[Frozen Active]:
    false
  15. Filter.SelectedStatusFilters[Frozen Selected]:
    false
  16. Filter.SelectedStatusFilters[Frozen Inactive]:
    false
But with EJ().CheckboxFor(), only selected ones get posted.

  1. Filter.SelectedStatusFilters[Potential]:
    true
  2. Filter.SelectedStatusFilters[Active]:
    true


3 Replies

PK Prem Kumar Madhan Raj Syncfusion Team February 12, 2018 12:18 PM UTC

Hi Kevin,   
  
Thanks for contacting Syncfusion Support.   
  
We have looked into your query and the checkboxFor components values are not accessed on postback and tried with a simple sample at our end. Unfortunately, we unable to reproduce the reported issue. We have also attached the sample with normal and EJ checkbox for components obtaining values on postback in the below link.   
  

  
In the above sample, Home/Index page contains a EJCheckBoxFor controls and Home/AboutPage contains HTML CheckboxFor control bound with model values from checkbox model class. On postback, both HTML CheckboxFor and EJCheckBoxfor controls return values in a similar way (both false and true values are obtained in name value pair). If this is not your case, please revert with an issue reproducing sample so that we can validate the reported issue and provide an exact solution for your requirement.   
  
Regards,   

Prem Kumar M



KF Kevin Finke February 13, 2018 11:49 AM UTC

The sample you sent still suffers the same problem, both in Edge and Chrome.  You'll notice that Keys1 is NOT present in the Form Data.






PK Prem Kumar Madhan Raj Syncfusion Team February 14, 2018 04:00 PM UTC

Hi Kevin,   
  
Sorry for the inconvenience.   
  
We have looked into the reported issue “checkbox not posting value when selected” and able to reproduce the reported issue at our end. We have considered this as an issue and logged a bug report in our database. The fix for this issue is expected to be available in three business days (19thFebruary 2018). We appreciate your patience until then.   
  
Regards,   
  
Prem Kumar. M

Loader.
Up arrow icon