Quantcast
Channel: MVC3 putting a newline in ViewBag text - Stack Overflow
Browsing latest articles
Browse All 5 View Live

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 Article



Answer 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 Article

Answer 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 Article

MVC3 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 Article

Answer 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

Browsing latest articles
Browse All 5 View Live




Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>