Copied to clipboard

Flag this post as spam?

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


  • Ross Ekberg 124 posts 364 karma points
    Apr 26, 2019 @ 13:45
    Ross Ekberg
    0

    Terratype in Partial View Macro

    Umbraco v7.13.2, Default Render Engine - Web Forms

    I am trying to get a terratype to display in my partial view macro. I'm doing this to try to display the location of a park. I created a data type called "Park Terratype" that has the terratype editor. I created a document type call "Park LIsting" that has a property call "parkMap" that uses the "Park Terratype" data type. In my partial view macro code I have the following:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Terratype
    
    @{
    var map = CurrentPage.Field<Terratype.Models.Model>("parkMap")
    
    @Html.Terratype(map)
    }
    

    This doesn't work. I get the following error:

    CS1973: 'HtmlHelper PartialViewMacroModel has no applicable method named 'Terratype' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

    What am I doing wrong?

  • Ross Ekberg 124 posts 364 karma points
    Apr 26, 2019 @ 21:13
    Ross Ekberg
    100

    I figured it out. For whatever reason, this produced a null value:

    CurrentPage.Field<Terratype.Models.Model>("parkMap");
    

    So I switched it to this:

    Model.Content.GetPropertyValue<Terratype.Models.Model>("parkMap");
    

    And now it works.

Please Sign in or register to post replies

Write your reply to:

Draft