Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C# export object to javascript, translate page controls

Posted on 2014-09-27
1
Medium Priority
?
235 Views
Last Modified: 2014-10-18
Our internal site has about 200 pages on it and each page has anywhere from 20-100 labels(controls) with titles that need translating.

We don’t do any controls in .NET ie. No serve side or runat.

We currently use Resource files with our 5 different languages and pivot off the users language to display the appropriate text/translation.

Looks something like this.


m.LangOutControl = GetLanguage();

    private string GetLanguage()
    {
        return string.Format("{0},{1},{2},{3},{4}",
              InnUtil.GetResourceLabel("plnCopytoNextPeriod", InnEnum.ResourceFile.App2),
              InnUtil.GetResourceLabel("labStrategy", InnEnum.ResourceFile.Common),
              InnUtil.GetResourceLabel("labAction", InnEnum.ResourceFile.Common),
              InnUtil.GetResourceLabel("labMeasure", InnEnum.ResourceFile.Common),
              InnUtil.GetResourceLabel("labIDP", InnEnum.ResourceFile.Common)
             );
    }

Open in new window



}

This returns a string to a JS function on the master page.

    <script type="text/javascript">
        function GetLangControl() { return '<%= LangOutControl %>'; }
    </script>

Open in new window


Then we put it into an object in JS and load populate the TEXT/HTML.

So I want to move this away from resource files and into our DB, create a tool that the owners of the Applications can manage the text/labels etc. by the appropriate language.

First question: Anyone have a different approach that might work for us.

Second question: How do I make my return an object so I don’t have to rely on position. Ie. From C# my return is this:

{
Lbl: “First Label”,
Lbl2: “Second label”
}

Open in new window

0
Comment
Question by:skillilea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 40348152
I believe this page answer your question : http://msdn.microsoft.com/en-us/library/bb412179(v=vs.110).aspx
So mainly the goal to create a DataContract which define your object with DataMember (which can be based on other DataContract) and use DataContractJsonSerializer to create this Javascript object
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question