Exemplo n.º 1
0
        private static HtmlTag CheckBox(ControlModel <bool> model, string tooltip, string helptext)
        {
            var checkBox = new HtmlTag("input");
            var id       = (string.IsNullOrWhiteSpace(model.Id) ? model.Name : model.Id);

            if (model.Value)
            {
                checkBox.Attr("checked", "checked");
            }

            checkBox.Name(model.Name);
            checkBox.Attr("type", "checkbox");
            // the value is always True
            checkBox.Value(bool.TrueString);
            checkBox.Id(id);
            checkBox.AddRules(model.Rules);

            var label = new Label <bool>(new ControlModel <bool>(id, model.Name, model.Value, model.DisplayName));

            // Tooltip
            if (!string.IsNullOrEmpty(tooltip))
            {
                label.AppendHtml(new Tooltip(tooltip).ToString());
            }

            // Help text
            if (!string.IsNullOrEmpty(helptext))
            {
                label.AppendHtml(new HelpText(helptext).ToString());
            }

            checkBox.Append(label);
            checkBox.Append(new HtmlTag("div", tag => tag.AddClass("chk-check")));

            return(checkBox);
        }