public static string RenderControlGroupDisplayText(HtmlHelper html, BootstrapDisplayTextModel inputModel, BootstrapLabelModel labelModel) { if (string.IsNullOrEmpty(inputModel.htmlFieldName)) { return(null); } var input = Renderer.RenderDisplayText(html, inputModel); string label = Renderer.RenderLabel(html, labelModel ?? new BootstrapLabelModel { htmlFieldName = inputModel.htmlFieldName, metadata = inputModel.metadata, htmlAttributes = new { @class = "control-label" }.ToDictionary(), showRequiredStar = false }); bool fieldIsValid = true; if (inputModel != null) { fieldIsValid = html.ViewData.ModelState.IsValidField(inputModel.htmlFieldName); } return(new BootstrapControlGroup(input, label, ControlGroupType.textboxLike, fieldIsValid).ToHtmlString()); }
public static string RenderDisplayText(HtmlHelper html, BootstrapDisplayTextModel model) { var input = html.DisplayText(model.htmlFieldName); TagBuilder containerDiv = new TagBuilder("div"); containerDiv.MergeAttributes(model.htmlAttributes.FormatHtmlAttributes()); containerDiv.AddCssStyle("padding-top", "5px"); containerDiv.InnerHtml = input.ToHtmlString(); return(containerDiv.ToString(TagRenderMode.Normal)); }