private static string GetDisplayText(IEnumerable <SelectListItem> selectList) { var stringBuilder = new StringBuilder(); foreach (SelectListItem selectListItem in selectList.Where(x => x.Selected)) { var builder = new HtmlTagBuilder("p"); builder.AddClass("form-control-static"); builder.InternalBuilder.SetInnerText(selectListItem.Text); stringBuilder.Append(builder.ToHtmlString()); } return(stringBuilder.ToString()); }
public static IHtmlString Render(HtmlHelper html, ITextBoxBuilder textBoxBuilder, FormGroupDisplay display, Func <object> valueFactory, Func <MvcHtmlString> hiddenField) { bool readOnlyMode = display == FormGroupDisplay.ReadOnly, labelWithHiddenFieldMode = display == FormGroupDisplay.LabelWithHiddenField; if (readOnlyMode || labelWithHiddenFieldMode) { var value = valueFactory(); var builder = new HtmlTagBuilder("p"); builder.Attr(textBoxBuilder.HtmlAttributes); builder.AddClass("form-control-static"); builder.InternalBuilder.SetInnerText(html.FormatValue(value, textBoxBuilder.Format())); if (labelWithHiddenFieldMode) { builder.InternalBuilder.InnerHtml += hiddenField(); } return(builder); } return(textBoxBuilder.AddClass("form-control")); }