månadsarkiv: september 2012

Making use of localized variables in javascript.

Here is a simple way of using values stored in global resource files to be used in your markup and javascript code. Simply add the following to your markup (aspx page, user control or whatever).

Once this is done, you can make use of the variable in your javascripts.

Note: These variables cannot be added in separate javascript files, but have to be added to the page directly. However, once added, they can be reached from code in the javascript file if it is imported.

EDIT: The GetGlobalResourceObject method is a standard method in the HttpContext class (link here).