javascriptasp.netline-breaksresxresource-files

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?


Solution

  • 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?"