Ejemplo n.º 1
0
        private static Control CreateCheckBox(Setting setting, bool diagnoseConflictingSettings)
        {
            Control           container = null;
            HtmlInputCheckBox checkBox  = null;

            try
            {
                string str       = setting.SettingId.ToString("N");
                string controlId = string.Concat(ControlIdPrefix, str);

                bool isChecked = false;
                if (!Boolean.TryParse(setting.Value, out isChecked))
                {
                    if (!Boolean.TryParse(setting.DefaultValue, out isChecked))
                    {
                        isChecked = false;
                    }
                }

                container = new Control();
                checkBox  = new HtmlInputCheckBox();
                checkBox.Attributes["class"] = "Nm";
                checkBox.ID      = controlId;
                checkBox.Checked = isChecked;
                if (diagnoseConflictingSettings)
                {
                    checkBox.Disabled = true;
                    checkBox.Style.Add(HtmlTextWriterStyle.Color, "Gray");
                }
                container.Controls.Add(checkBox);

                return(container);
            }
            finally
            {
                if (container != null)
                {
                    container.Dispose();
                }
                if (checkBox != null)
                {
                    checkBox.Dispose();
                }
            }
        }