最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - Set the Resource String in javascript - Stack Overflow

programmeradmin5浏览0评论

How can I set the resource string in javascript?

I have a resource file called, for example,

myResourceFile.resx

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%>" />

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;"
            ...
/>

or

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

Thanks

How can I set the resource string in javascript?

I have a resource file called, for example,

myResourceFile.resx

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%>" />

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;"
            ...
/>

or

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

Thanks

Share Improve this question asked Mar 10, 2009 at 14:41 balexandrebalexandre 75.1k47 gold badges238 silver badges350 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 16

You should be able to use:

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

评论列表(0)

  1. 暂无评论