0

I'm facing single quote (') issue inside RESX files while I call them directly in JavaScript, such as:

var hello = '<%=SomeTextFromResxWithSingleQuote%>';

In this case all the JavaScript is mixed up and many bugs appear :( Any fast solution to solve this? Thanks :)

Or Assayag
  • 4,346
  • 10
  • 43
  • 76

2 Answers2

1

You can use double quotes to skip this issue such as:

var hello = "<%=SomeTextFromResxWithSingleQuote%>";

JavaScript allows you to use either double or single quotes to delimit text.

When to use double or single quotes in JavaScript?

Community
  • 1
  • 1
Ghasan غسان
  • 5,219
  • 4
  • 30
  • 41
0

Solved.

string fixedText = ReplaceSingleQuote("L'df'ds");

public static ReplaceSingleQuote(string text)
{
        if (string.IsNullOrEmpty(text))
        {
            return text;
        }
        return text.Replace("'", "&apos;");
}
Or Assayag
  • 4,346
  • 10
  • 43
  • 76