Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 298
Li Tian Gong Avatar asked Jun 04 '12 04:06

Li Tian Gong


2 Answers

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.

like image 110
Leniel Maccaferri Avatar answered Oct 05 '22 23:10

Leniel Maccaferri


Try shift-enter to create a new line in the designer. Alternatively copy and paste the result from notepad.

Another way is to edit the RESX xml manually.

The problem is that the RESX designer UI will auto-escape the strings. So your value is actually:

"Invalid URL! \\n Are you sure you want to continue?"
like image 42
Robert Wagner Avatar answered Oct 06 '22 01:10

Robert Wagner