asp.net: line break \n in resource .resx file does not work

Li Tian Gong picture Li Tian Gong · Jun 4, 2012 · Viewed 10.3k times · Source

The "\n" does not work in below code, it's just displayed as "\n"

if (!window.confirm(XXXXX.Globalization.LocalResource.InvalidUrl)) {
    return false;
}

the string is "Invalid URL! \n Are you sure you want to continue?" in resource resx file.

how to make it work?

Answer

Leniel Maccaferri picture Leniel Maccaferri · Aug 1, 2012

What worked in my case was this:

This text has a<br>line break!

See the <br> there.

Look here for the details: Putting a line break in an resx resource file

I'm using Razor in ASP.NET MVC and so I used:

@Html.Raw(Localization.NotAnswered)

so that it outputs the <br> as HTML code.