x First time here? Check out the FAQ
Join us a the Umbraco event of the year - get your Codegarden 14 early bird ticket today
  • Avatar2966posts5174karma
    admin

    Razor dictionary in usercontrol

    Ismail Mayat started this topic March 13, 2012 @ 11:32, Go directly to the topic solution

    Hello,

    In a razor macro you can do Dictionary.Blah. What i want to do is use the dynamic dictionary object in a usercontrol so i dont have to keep doing umbraco.library.GetDictionaryItem("blah"). Is it possible to do this if it is then how.

    Many thanks

     

    Ismail


  • Rodion Novoselov posted this reply March 13, 2012 @ 01:36

    Hi. I think you can use a raw CultureDictionary object (in the umbraco.MacroEngines namespace) like this:

    private CultureDictionary cultureDictionary;

    protected dynamic Dictionary
    {
       get {
          cultureDictionary = cultureDictionary ?? new CultureDictionary();
          return cultureDuctionary;
       }

     


  • Avatar2966posts5174karma
    adminComment with ID: 110701
    Ismail Mayat posted this reply March 13, 2012 @ 03:31

    Rodion,

    Many thanks just a slight tweak to the code :

     

     private UmbracoCultureDictionary cultureDictionary;

     

            protected dynamic Dictionary

            {

                get

                {

                    cultureDictionary = cultureDictionary ?? new UmbracoCultureDictionary();

                    return cultureDictionary;

                   

                }

            } 

     

    Regards

     

    Ismail


Please login or Sign up To post replies