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.
But with EJ().CheckboxFor(), only selected ones get posted.