1 Replies - 5707 Views - Last Post: 06 May 2012 - 08:06 AM

#1 drilli  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 105
  • Joined: 26-May 09

Pass resx files in client side as JSON or Javascript objects

Posted 06 April 2012 - 08:39 AM

Hi all.
I am trying to internationalize my web application wich I developed in MVC 3.0.

I can read my values in .resx files from cshtml, but how can I read these values(in .resx files) from my .js files.
Is there any way to serialize or convert .resx files in JSON objects(in controllers in server side) and return that object.After that in this object I can read all ky/value pairs wothout any problem.

Is this possible or do you know any better solution of this problem.

Generaly asking: How to access values in .resx files from clients site javascript files .js ?

Thank You for reading this question and for everyone who can help me.

Is This A Good Question/Topic? 0
  • +

Replies To: Pass resx files in client side as JSON or Javascript objects

#2 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Pass resx files in client side as JSON or Javascript objects

Posted 06 May 2012 - 08:05 AM

You can use jQuery's data attributes to set the values in your View, then you can access them via your .js scripts.

//Some View:
<button data-foovalue="@Model.SomeValueFromResx">Foo</button>

//In your Javascript:
var valueFound = $(this).data("foovalue");


This post has been edited by Sergio Tapia: 06 May 2012 - 08:06 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1