Copied to clipboard

Flag this post as spam?

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


  • David Prothero 23 posts 106 karma points
    Jul 29, 2013 @ 00:23
    David Prothero
    0

    MacroParameters not being passed from Umbraco.RenderMacro

    I have a partial view that is my standard header. It calls the following:

    @Umbraco.RenderMacro("Image", new {propertyName="headerLogo"})

    So, this is supposed to pass "propertyName" as a macro parameter. In my Image.cshtml, I have this code to read that property:

    string headerImageId = (string)Model.Content.GetPropertyValue((string)Model.MacroParameters["propertyName"]);

    The bolded portion, the access attempt to Model.MacroParameters["propertyName"], is throwing a KeyNotFoundException ("The given key was not present in the dictionary").

    This was working fine, but has stopped working. Not sure if it was due to upgrading from 6.1.1 to 6.1.2 or not. I upgraded to 6.1.3 and the problem persists. It's simply not passing the macro parameter to the macro.

    Anyone have any thoughts?

    Thanks,

    David

  • David Prothero 23 posts 106 karma points
    Jul 29, 2013 @ 02:29
    David Prothero
    100

    FIXED: Did not realize that this wasn't entirely a coding construct. Went into the back-office and saw the parameter for the Image.cshtml macro was named "propertyAlias" instead of propertyName. Changed the code and it all works.

Please Sign in or register to post replies

Write your reply to:

Draft