Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Gregory 87 posts 233 karma points
    Feb 05, 2019 @ 16:37
    David Gregory
    0

    Umbraco.GetDictionaryValue in View

    Hello all

    How do I call @Umbraco.GetDictionaryValue in a view if my Model is custom?

    i.e I don't have @inherits Umbraco.Web.Mvc.UmbracoTemplatePage at the top.

    David

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Feb 05, 2019 @ 17:14
    Nik
    0

    Hi David,

    What do you have at the top of your view? Is the view being called via a custom route/controller? or from an Umbraco Surface Controller, or directly from an Umbraco view?

    Thanks

    Nik

  • David Gregory 87 posts 233 karma points
    Feb 05, 2019 @ 19:32
    David Gregory
    0

    Just @model List

    I've tried adding using Umbraco.Core and Web but it doesn't like it.

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Feb 05, 2019 @ 21:05
    Nik
    101

    Hi David,

    If you remove @model and use @inherits UmbracoViewPage<List> (assuming List is the name of your type)

    You should get access to @Umbraco, and @Model will be you model as you expect :-)

    Give that a go

    Nik

  • David Gregory 87 posts 233 karma points
    Feb 05, 2019 @ 21:45
    David Gregory
    0

    Fantastic, that works. Just what I needed.

    Where could I have found that out, is there a page in the documentation that would have told me?

    Thanks again. David

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Feb 06, 2019 @ 08:55
    Nik
    0

    Hi David,

    Honestly, I'm sure sure where in the documentation you would have found it. I'm pretty sure it's in there somewhere when it's talking about surface controllers but I'm not 100%.

    I think I've picked it up from either the Umbraco Training Courses (I highly recommend them if you can), or other forum posts / discussions on Slack :-)

    Nik

Please Sign in or register to post replies

Write your reply to:

Draft