簡體   English   中英

在 javascript 中設置資源字符串

[英]Set the Resource String in javascript

如何在 javascript 中設置資源字符串?

我有一個資源文件,例如,

myResourceFile.resx

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

lblName.Text = Resources.myResourceFile.ajaxRetrievingInformation;

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

但是如果我在 javascript 中嘗試這個,比如:

<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>

我收到錯誤...

有誰知道如何管理這個?

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

謝謝

您應該能夠使用:

<script type="text/javascript">
    var strLoadingText = "<%= Resources.myResourceFile.ajaxRetrievingInformation %>";
</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM