Sorry about the simple question but I can't seem to figure it out by myself.
The documentation (and a lot of forum posts) say that to use umbraco dictionary items I simply need to do
@Dictionary.MyItemKey
I am trying to do just that in a partial view and I can't get it to compile / work. I probably have a missing @using directive, but which one? Where is the @Dictionary helper defined (i.e. what do I need to add to my cshtml file to make it work)? The following works fine, I am just trying to do it the dynamic way.
Yes I have actually and I still end up with errors when I run it (the same error I get with @Dictionary.MyItemKey :
Using the generic type 'System.Collections.Generic.Dictionary<TKey,TValue>' requires 2 type arguments
So obviously there is something missing for the interpreter to make the difference between umbraco's dictionary helper and the normal System.Collections.Generic.Dictionary and this is what i'm looking for
I have just seen the video on Umbraco TV about dictionary items, just to see how they suggestto work with dictionary items, and they are using this syntax.
That is great to hear, I am glad that I could help you out.
In MVC @Umbraco (of type Umbraco.Web.UmbracoHelper) -> contains many helpful methods, from rendering macros and fields to retreiving content based on an Id and tons of other helpful methods. This is essentially the replacement for the 'library' object in the old codebase.
Could you please mark the question as solved, so other that come across the question, can see what is worked for you.
Dictionary Items in Razor
Hi,
Sorry about the simple question but I can't seem to figure it out by myself.
The documentation (and a lot of forum posts) say that to use umbraco dictionary items I simply need to do
I am trying to do just that in a partial view and I can't get it to compile / work. I probably have a missing @using directive, but which one? Where is the @Dictionary helper defined (i.e. what do I need to add to my cshtml file to make it work)? The following works fine, I am just trying to do it the dynamic way.
Thanks!
Hi Hugo,
Have tried to do it this way?
Hope this helps,
/Dennis
Yes I have actually and I still end up with errors when I run it (the same error I get with @Dictionary.MyItemKey :
Using the generic type 'System.Collections.Generic.Dictionary<TKey,TValue>' requires 2 type arguments
So obviously there is something missing for the interpreter to make the difference between umbraco's dictionary helper and the normal System.Collections.Generic.Dictionary and this is what i'm looking for
Thanks for you help,
-Hugo
Hi Hugo,
I have just seen the video on Umbraco TV about dictionary items, just to see how they suggest to work with dictionary items, and they are using this syntax.
So when you are in MVC you need to use @Umbraco.GetDictionaryValue("MyItemKey") you can find the documentation here: http://our.umbraco.org/documentation/reference/Querying/UmbracoHelper/#GetDictionaryValue%28stringkey%29
/Dennis
Hi Dennis,
Thanks, it does work with the umbraco helper (@Umbraco.GetDictionaryValue) so I will go with that.
I'm still curious as to how to get the @Dictionary helper though!
Thanks again for your help
-Hugo
Hi Hugo,
That is great to hear, I am glad that I could help you out.
In MVC @Umbraco (of type
Umbraco.Web.UmbracoHelper
) -> contains many helpful methods, from rendering macros and fields to retreiving content based on an Id and tons of other helpful methods. This is essentially the replacement for the 'library' object in the old codebase.Could you please mark the question as solved, so other that come across the question, can see what is worked for you.
/Dennis
is working on a reply...