protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        foreach (KeyValuePair <int, Panel> pair in categoryToPanelMap)
        {
            pair.Value.Visible = !ExcludedCategories.Contains(pair.Key);
        }

        string script = "function Check(check) {" +
                        " $cmsj(\"#" + pnlFilterOptions.ClientID + " :input:checkbox\").prop('checked', check);" +
                        "}";

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Actions", ScriptHelper.GetScript(script));
    }
    /// <summary>
    /// Generates the checkboxes.
    /// </summary>
    /// <param name="skuIdOfProductWithCategories">The SKU id of product with categories.</param>
    private void GenerateCheckboxes(int skuIdOfProductWithCategories)
    {
        optionToCheckBoxMap.Clear();
        optionToCategoryMap.Clear();

        Dictionary <int, string> categoriesWithName = GetCategoriesWithNames(skuIdOfProductWithCategories);

        foreach (KeyValuePair <int, string> pair in categoriesWithName)
        {
            int    categoryId   = pair.Key;
            string categoryName = pair.Value;

            // Ignore excluded categories
            if (ExcludedCategories.Contains(categoryId))
            {
                continue;
            }

            Dictionary <int, string> optionsWithNames = GetOptionsWithNames(skuIdOfProductWithCategories, categoryId);

            if (optionsWithNames == null || optionsWithNames.Count == 0)
            {
                continue;
            }

            var row = new Panel
            {
                CssClass = "form-group"
            };
            pnlFilterOptions.Controls.Add(row);
            // Label text set to CategoryDisplayName
            var lblCategoryDisplayName = new Label
            {
                Text     = String.Format("{0}:", HTMLHelper.HTMLEncode(ResHelper.LocalizeString(categoryName))),
                CssClass = "control-label"
            };

            var chbl = new CMSCheckBoxList
            {
                RepeatDirection = RepeatDirection.Horizontal
            };

            var cellLabel = new Panel
            {
                CssClass = "filter-form-label-cell"
            };
            var cellCheckBoxList = new Panel
            {
                CssClass = "filter-form-value-cell-wide"
            };

            cellLabel.Controls.Add(lblCategoryDisplayName);
            cellCheckBoxList.Controls.Add(chbl);

            row.Controls.Add(cellLabel);
            row.Controls.Add(cellCheckBoxList);
            // Category to table row mapping
            categoryToPanelMap.Add(categoryId, row);
            // Fill new checkboxlist with options from category
            FillCheckboxlist(optionsWithNames, chbl, categoryId);
        }
    }