Search code examples
htmlasp.net-mvc-3newlineinternet-explorer-7pre

Newline in a <pre> element in internet explorer 7


I have the following code in my ASP.NET MVC 3 project:

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
...    
<pre>@Html.ValidationSummary()</pre>

The validationsummary shows the errormessages that are specified in my model. And the model gets the errormessages out of a resource file..
In 1 of the errormessages I use newlines (shift + enter).
These newlines are shown correctly in firefox and chrome, but not in internet explorer 7.

Can I fix this?


Solution

  • It's possible that the ValidationSummary() uses unix newlines (\n) and IE only likes the Windows newlines (\r\n). See if you can replace \n with \r\n in before displaying it.