umbracoumbraco6umbraco5umbraco-blogumbraco-contour

How can we to access value of umbraco dictionary item from Javascript


Can we access Umbraco Dictionary item value from JavaScript ?

As I am using Umbraco 6.0.5


Solution

  • What I have done is declare variable in using Javascript

    <script type="text/javascript">    
        var UmbracoDicKeyValue = '<%= kraftvaerk.umbraco.Translations.translate("Umbraco_Dic_Key", lang) %>';
    </script>
    

    And for setting value of lang variable from server side.

    protected string lang = (!String.IsNullOrEmpty(umbraco.library.Session("lang")) ? umbraco.library.Session("lang") : "en-GB");
    umbraco.library.setSession("lang", lang);
    

    Now use variable UmbracoDicKeyValue in javascript code.