在javascript中设置资源字符串

bal*_*dre 8 javascript asp.net resources .net-3.5

如何在javascript中设置资源字符串?

我有一个名为的资源文件,例如,

myResourceFile.resx
Run Code Online (Sandbox Code Playgroud)

在我的代码中使用我可以使用的文字控件:

lblName.Text = Resources.myResourceFile.ajaxRetrievingInformation;

<asp:Literal id="lit" runat="server" 
             Text="<%$ Resources:myResourceFile, ajaxRetrievingInformation%>" />
Run Code Online (Sandbox Code Playgroud)

但如果我在javascript中尝试这个,比如:

<asp:Button ID="btnImportCompaniesAndEmployees" 
            runat="server" 
            CssClass="myButtonCssClass"
            OnClick="btnImportCompaniesAndEmployees_Click"
            OnClientClick="strLoadingText='<%$ Resources:myResourceFile, ajaxRetrievingInformation%>';return true;"
            ...
/>
Run Code Online (Sandbox Code Playgroud)

要么

<script type="text/javascript">
    var strLoadingText = '<%$ Resources:myResourceFile, ajaxRetrievingInformation%>';
</script>
Run Code Online (Sandbox Code Playgroud)

我收到错误......

有谁知道如何管理这个? 像这样的东西:

var strLoadingText = Resources.GetString(myResourceFile, ajaxRetrievingInformation);
Run Code Online (Sandbox Code Playgroud)

谢谢

Joe*_*oel 16

你应该可以使用:

<script type="text/javascript">
    var strLoadingText = "<%= Resources.myResourceFile.ajaxRetrievingInformation %>";
</script>
Run Code Online (Sandbox Code Playgroud)