The display template is probably the best solution, but there is another easy way to use the html helper if you know that you are just showing a string, for example:
namespace Shaul.Web.Helpers { public static class HtmlHelpers { public static IHtmlString ReplaceBreaks(this HtmlHelper helper, string str) { return MvcHtmlString.Create(str.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None).Aggregate((a, b) => a + "<br />" + b)); } } }
And then you will use it like:
@using Shaul.Web.Helpers @Html.ReplaceBreaks(Model.MultiLineText)
Ian Routledge Jan 27 '12 at 10:17 2012-01-27 10:17
source share