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 3072 posts 13628 karma points MVP 10x 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.

Please Sign in or register to post replies

Write your reply to:

Draft