Use ASP.NET Resource strings from within javascript files

后端 未结 9 1701
迷失自我
迷失自我 2020-12-13 01:02

How would one get resx resource strings into javascript code stored in a .js file?

If your javascript is in a script block in the markup, you can use this syntax:

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 01:20

    There's no native support for this.

    I built a JavaScriptResourceHandler a while ago that can serve Serverside resources into the client page via objects where each property on the object represents a localization resource id and its value. You can check this out and download it from this blog post:

    http://www.west-wind.com/Weblog/posts/698097.aspx

    I've been using this extensively in a number of apps and it works well. The main win on this is that you can localize your resources in one place (Resx or in my case a custom ResourceProvider using a database) rather than having to have multiple localization schemes.

提交回复
热议问题