Пример #1
0
        public static IHtmlContent MultlineText(this IHtmlHelper htmlHelper, string text)
        {
            var sb = new StringBuilder();

            var lines = TextUtility.DecodeMultilineText(text);

            for (int idx = 0; idx < lines.Length; ++idx)
            {
                if (idx > 0)
                {
                    _ = sb.Append("<br>");
                }
                _ = sb.Append(htmlHelper.Encode(lines[idx]));
            }

            return(new HtmlString(sb.ToString()));
        }
Пример #2
0
        public static IHtmlContent DisplayForMultilineText <TModel>(this IHtmlHelper <TModel> htmlHelper, Expression <Func <TModel, string> > expression)
        {
            var expressionValue = expression.Compile()(htmlHelper.ViewData.Model);

            var sb = new StringBuilder();

            var lines = TextUtility.DecodeMultilineText(expressionValue);

            for (int idx = 0; idx < lines.Length; ++idx)
            {
                if (idx > 0)
                {
                    _ = sb.Append("<br>");
                }
                _ = sb.Append(htmlHelper.Encode(lines[idx]));
            }

            return(new HtmlString(sb.ToString()));
        }