... having to get Razor help from the Xslt Rebel Alliance, this is a total embarrasment :)
Thanks for the tip.
Sebastian (@Cultiv) also gave me some help. Dictionary Items can be accessed in Razor script using the umbraco.library.GetDictionaryItem("DictionaryItem")
The cheat sheet still needs some updates. Yes, you can find it in the documentation...
Since this IS documentation...
As of 7.x, you can use
@{
Umbraco.Field("#DictionaryTerm");
}
I just used this today:
@{
var download = Umbraco.Field(#Download").ToString(); // call ToString() otherwise it is IHtmlString
}
<span class="button">@download</span>
//** Almost 3 years later...
I am working on a partial view that only inherits a custom view model and couldn't use Umbraco.Field. So in that scenario, this is what to use:
access Dictionary Items with Razor
Hi,
How can I access the value of a Dictionary Item from within a Razor script (.cshtml)?
Thanks for your help,
Anthony
Hi Anthony
It actually seems it's covered a little bit in the Razor Cheat Sheet in the lower left section named "Dictionary".
Hope this helps :)
/Jan
Hi Jan,
... having to get Razor help from the Xslt Rebel Alliance, this is a total embarrasment :)
Thanks for the tip.
Sebastian (@Cultiv) also gave me some help. Dictionary Items can be accessed in Razor script using the umbraco.library.GetDictionaryItem("DictionaryItem")
This works great me.
Jeavon Leopold (@crumpled_jeavon) pointed me to and example using the Dictionary Picker in Razor
greetings,
Anthony
I checked the Razor DynamicNode Cheatsheet, this code does the job:
@Dictionary["dictionaryItemAlias"]
greetings,
Anthony
Hi Anthony
I'm just happy I was able to help you out so you can make awesomeness in Umbraco :)
Have fun mate.
/Jan
FYI the Umbraco Documentation has now documentation on using Dictionary Items in Razor
greetings,
Anthony
The cheat sheet still needs some updates. Yes, you can find it in the documentation...
Since this IS documentation...
As of 7.x, you can use
I just used this today:
//** Almost 3 years later... I am working on a partial view that only inherits a custom view model and couldn't use Umbraco.Field. So in that scenario, this is what to use:
is working on a reply...