Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何覆盖读取RESX文件事件?_Javascript_C# - Fatal编程技术网

Javascript 如何覆盖读取RESX文件事件?

Javascript 如何覆盖读取RESX文件事件?,javascript,c#,Javascript,C#,当我在JavaScript中直接调用RESX文件时,我遇到了RESX文件中的单引号(')问题,例如: var hello = '<%=SomeTextFromResxWithSingleQuote%>'; var hello=''; 在这种情况下,所有JavaScript都混淆了,出现了许多错误:( 有什么快速的解决办法吗? 谢谢:)已解决 string fixedText = ReplaceSingleQuote("L'df'ds"); public static Repla

当我在JavaScript中直接调用RESX文件时,我遇到了RESX文件中的单引号(')问题,例如:

var hello = '<%=SomeTextFromResxWithSingleQuote%>';
var hello='';
在这种情况下,所有JavaScript都混淆了,出现了许多错误:( 有什么快速的解决办法吗? 谢谢:)

已解决

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

public static ReplaceSingleQuote(string text)
{
        if (string.IsNullOrEmpty(text))
        {
            return text;
        }
        return text.Replace("'", "&apos;");
}

您可以使用双引号跳过此问题,例如:

var hello = "<%=SomeTextFromResxWithSingleQuote%>";
var hello=”“;
JavaScript允许您使用双引号或单引号来分隔文本


无需使用THO,只需使用双引号来分隔文本即可。请看我的答案。最好不要引用,而不要将其替换为
&apos因为转义字符串可以在任何地方使用,并且
&apos仅适用于HTML。