Example #1
0
        public override void WriteToOutput(ControlFormAttribute formAttribute, string inputControl)
        {
            if (!string.IsNullOrEmpty(formAttribute.ContainerCssClass))
            {
                builder.AppendFormat("<div class=\"{0}\">", formAttribute.ContainerCssClass);
            }

            builder.AppendFormat("<div class=\"form-group\" data-bind=\"{0}\">", formAttribute.ContainerDataBind);

            if (formAttribute.HasLabelControl && !formAttribute.HideLabelControl)
            {
                builder.AppendFormat("<label for=\"{2}\" class=\"{1}\">{0}</label>", formAttribute.LabelText ?? formAttribute.Name, formAttribute.LabelCssClass, formAttribute.Name.Replace(".", "_").Replace("[", "_").Replace("]", "_"));
            }

            if (string.IsNullOrEmpty(formAttribute.ControlContainerCssClass))
            {
                builder.Append(inputControl);
            }
            else
            {
                builder.AppendFormat("<div class=\"{0}\">", formAttribute.ControlContainerCssClass);
                builder.Append(inputControl);
                builder.Append("</div>");
            }

            builder.Append("</div>");

            if (!string.IsNullOrEmpty(formAttribute.ContainerCssClass))
            {
                builder.Append("</div>");
            }
        }
Example #2
0
        public override void WriteToOutput(ControlFormAttribute formAttribute, params string[] inputControls)
        {
            if (inputControls == null || inputControls.Length == 0)
            {
                return;
            }

            var hasLabelControl  = false;
            var controlsCssClass = string.Empty;

            WriteToOutput(formAttribute != null && !string.IsNullOrEmpty(formAttribute.ContainerDataBind)
                ? string.Format("<div class=\"{1}\" data-bind=\"{0}\">", formAttribute.ContainerDataBind, GroupCssClass)
                : string.Format("<div class=\"{0}\">", GroupCssClass));

            if (formAttribute != null)
            {
                if (formAttribute.HasLabelControl)
                {
                    hasLabelControl = true;
                    WriteToOutput(formAttribute.HideLabelControl
                        ? string.Format("<label class=\"{0}\">&nbsp;</label>", LabelCssClass)
                        : string.Format("<label class=\"{2}\" for=\"{1}\">{0}</label>",
                                        formAttribute.LabelText ?? formAttribute.PropertyName ?? formAttribute.Name,
                                        formAttribute.Name.Replace(".", "_").Replace("[", "_").Replace("]", "_"), LabelCssClass));
                }
            }
            else
            {
                hasLabelControl  = true;
                controlsCssClass = " form-buttons";
            }

            if (hasLabelControl)
            {
                WriteToOutput(string.Format("<div class=\"{0}\">", ControlsCssClass + controlsCssClass));
            }

            var renderSpaces = false;

            foreach (var inputControl in inputControls.Where(x => x != null))
            {
                if (renderSpaces)
                {
                    WriteToOutput("&nbsp;&nbsp;&nbsp;");
                }
                WriteToOutput(inputControl);
                renderSpaces = true;
            }

            if (hasLabelControl)
            {
                WriteToOutput("</div>");
            }

            WriteToOutput("</div>");
        }
        public override void WriteToOutput(ControlFormAttribute formAttribute, params string[] inputControls)
        {
            if (inputControls == null || inputControls.Length == 0)
            {
                return;
            }

            WriteToOutput(formAttribute != null && !string.IsNullOrEmpty(formAttribute.ContainerDataBind)
                ? string.Format("<div class=\"row\" data-bind=\"{0}\">", formAttribute.ContainerDataBind)
                : "<div class=\"row\">");

            if (formAttribute == null)
            {
                WriteToOutput("<label>&nbsp;</label>");
            }
            else
            {
                if (formAttribute.HasLabelControl)
                {
                    WriteToOutput(formAttribute.HideLabelControl
                        ? string.Format("<label>&nbsp;</label>")
                        : string.Format("<label for=\"{1}\">{0}</label>",
                                        formAttribute.LabelText ?? formAttribute.PropertyName ?? formAttribute.Name,
                                        formAttribute.Name.Replace(".", "_").Replace("[", "_").Replace("]", "_")));
                }
            }

            var renderSpaces = false;

            foreach (var inputControl in inputControls.Where(x => x != null))
            {
                if (renderSpaces)
                {
                    WriteToOutput("&nbsp;&nbsp;&nbsp;");
                }
                WriteToOutput(inputControl);
                renderSpaces = true;
            }

            WriteToOutput("</div>");
        }
 public abstract void WriteToOutput(ControlFormAttribute formAttribute, params string[] inputControls);
 public abstract void WriteToOutput(ControlFormAttribute formAttribute, string inputControl);
 public override void WriteToOutput(ControlFormAttribute formAttribute, string inputControl)
 {
     throw new NotImplementedException();
 }