Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use .net Resource files in javascript

is there anyway i can access my resource files (.resx) in javascript?
if no then are there any workarounds to diplay messages in javascript in different languages?

like image 772
scatman Avatar asked Sep 24 '10 08:09

scatman


2 Answers

If your javascript is in the page you can use:

var globalResource = '<%= Resources.YourClass.YourResourceKey %>';

to access the Global Resources (/App_GlobalResources). Or

var localResource = '<%= GetLocalResourceObject("LocalResourceKey").ToString() %>';

to access the Local resources (/App_LocalResources relative to the page position).

Or a javascript solution may be this nice jQuery plugin.

like image 159
tanathos Avatar answered Oct 14 '22 04:10

tanathos


i did it by using Jquery ajax which calls a serverside GetGlobalResourceObject()

like image 40
scatman Avatar answered Oct 14 '22 04:10

scatman