Asp.net: line break \ n in .resx file not working

"\ n" does not work in the lower code, it just displays as "\ n"

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

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

how to make it work?

+5
source share
6 answers

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

Another way is to edit RESX xml manually.

The problem is that the RESX developer user interface will automatically avoid strings. So your value is valid:

"Invalid URL! \\n Are you sure you want to continue?"
+5
source

Which in my case was like this:

This text has a<br>line break!

See <br>there.

: resx

Razor ASP.NET MVC, :

@Html.Raw(Localization.NotAnswered)

<br> HTML-.

+7

break "<br/>" "\n"

use "\r\n"
0

shift + enter, .

<br> , \r\n, \n , \r\n

0

ASP.NET MVC

-1
Resource.resx Shift+Enter 1 2
paragraph1
paragraph2

-2

<p>@Html.Raw(Regex.Replace(Resource.Mytext, "\r\n", "<br />"))</p>
0

Shift-enter works fine when you enter lines, but if you already created your resource file and you don't want to edit each line, you can just do

String myStringFromResx = myStringFromResx.Replace("\\n," "\n");
-1
source

All Articles