- Home
- Forum
- ASP.NET MVC
- Post checkboxes even when not selected
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.
- Filter.SelectedStatusFilters[Website]:false
- Filter.SelectedStatusFilters[Denied]:false
- Filter.SelectedStatusFilters[Potential]:true
- Filter.SelectedStatusFilters[Potential]:false
- Filter.SelectedStatusFilters[Review]:false
- Filter.SelectedStatusFilters[Testing]:false
- Filter.SelectedStatusFilters[Active]:true
- Filter.SelectedStatusFilters[Active]:false
- Filter.SelectedStatusFilters[Selected]:false
- Filter.SelectedStatusFilters[Inactive]:false
- Filter.SelectedStatusFilters[Retired]:false
- Filter.SelectedStatusFilters[Dropped]:false
- Filter.SelectedStatusFilters[Deleted]:false
- Filter.SelectedStatusFilters[Frozen Active]:false
- Filter.SelectedStatusFilters[Frozen Selected]:false
- Filter.SelectedStatusFilters[Frozen Inactive]:false
But with EJ().CheckboxFor(), only selected ones get posted.
- Filter.SelectedStatusFilters[Potential]:true
- Filter.SelectedStatusFilters[Active]:true
SIGN IN To post a reply.
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,
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
KF Kevin Finke
- Feb 10, 2018 05:43 PM UTC
- Feb 14, 2018 04:00 PM UTC