设置资源字符串在javascript字符串、资源、javascript

2023-09-07 03:35:55 作者:unnecessary(多余)

如何设置JavaScript中的资源字符串?

How can I set the resource string in javascript?

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

I have a resource file called, for example,

myResourceFile.resx

在我的code和使用文字的控制,我可以使用:

in my code and using the literal control I can use:

lblName.Text = Resources.myResourceFile.ajaxRetrievingInformation;

<asp:Literal id="lit" runat="server" 
             Text="<%$ Resources:myResourceFile, ajaxRetrievingInformation%>" />

但如果我尝试这在JavaScript中,这样的:

but if I try this in javascript, like:

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

<script type="text/javascript">
    var strLoadingText = '<%$ Resources:myResourceFile, ajaxRetrievingInformation%>';
</script>

我得到的错误...

I get errors...

有谁知道如何管理呢? 类似于

Does anyone know how to manage this? Something like:

var strLoadingText = Resources.GetString(myResourceFile, ajaxRetrievingInformation);

感谢

推荐答案

您应该能够使用:

<script type="text/javascript">
    var strLoadingText = "<%= Resources.myResourceFile.ajaxRetrievingInformation %>";
</script>
 
精彩推荐
图片推荐