Answer by Joe for MVC3 putting a newline in ViewBag text
This worked for me : Controller: ViewBag.Msg += Environment.NewLine + "xxxx"; View: <p class="@ViewBag.MsgColor"> @Html.Raw(@ViewBag.Msg.Replace(Environment.NewLine, "<br/>")) </p>
View ArticleAnswer by devstruck for MVC3 putting a newline in ViewBag text
When you throw into your view, use @Html.Raw(ViewBag.Test) instead of @ViewBag.Test That will signify to the compiler that string is html and does not need to be encoded as such.
View ArticleAnswer by user596075 for MVC3 putting a newline in ViewBag text
Use a string[] to hold your errors. That way they are a well-formed and distinct set of errors instead of just one long string. In your Controller, initializing the ViewBag property: ViewBag.Errors =...
View ArticleMVC3 putting a newline in ViewBag text
I have an MVC3 C#.Net web app. I am looping through a DataTable. Some rows are importing OK, some are not. I am wanting to send a list of errors back to the view in a list format. I am assigning the...
View ArticleAnswer by Dan B for MVC3 putting a newline in ViewBag text
My preferred way of doing this is to simply add a <br /> to the line time in the controller code as ViewData["msg"] which can then be pulled from the razor page as below.Controller...
View Article
More Pages to Explore .....