Copied to clipboard

Flag this post as spam?

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


  • David 29 posts 110 karma points
    Jul 02, 2013 @ 05:18
    David
    0

    Dynamic macro parameter syntax, using an Umbraco field as value

    Hi,

    I'm new to Razor and Umbraco and have a syntax question.

    I'm trying to insert an Umbraco field as a macro's parameter, is something like this possible?

     

    Umbraco.RenderMacro("MyMacro", new {MyParam=Umbraco.Field("myField")})

    Thanks.

  • Jeavon Leopold 3008 posts 13221 karma points MVP 7x admin c-trib
    Jul 02, 2013 @ 11:25
    Jeavon Leopold
    0

    Hi David,

    I think you need to access your property using Model.Content.GetPropertyValue method, e.g.

    @Umbraco.RenderMacro("MyMacro", new {MyParam = Model.Content.GetPropertyValue<string>("myField")});

    Thanks,

    Jeavon

  • David 29 posts 110 karma points
    Jul 13, 2013 @ 21:28
    David
    1

    Thanks, I ended up creating a partial view instead of a macro.

    Cheers.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies