Blog

Using ASP.NET Web Page Resources in Javascript

By Denisse Zavala

Sharing server variables with client side scripts is nowadays a situation than can be easily overcome by choosing one of the several existing approaches.

When it comes to accessing the values stored in the .resx file the story is not different, and in this post you can find a really simple way to achieve it.

1.      Add a web form to the web site, clear the markup so that only the @Page directive is present:

1

2.      Use the Page_Load event handler to render the resources’ values as Javascriptmembers:

2

3.      Use a ScriptManager control in the master page to register the script created:

3

4.      Now the resources are available throughout the client scripts using them as follows:

4
 

Comments

Leave a comment

 
 
 
 
CAPTCHA Image Validation