How to use .net Resource files in javascript

scatman picture scatman · Sep 24, 2010 · Viewed 22.7k times · Source

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?

Answer

tanathos picture tanathos · Sep 24, 2010

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.