Copied to clipboard

Flag this post as spam?

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


  • Steve 140 posts 321 karma points
    Sep 27, 2015 @ 03:00
    Steve
    0

    Partial View Macro parameters when rendered from code

    Hi, I have a simple Partial View Macro:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @{
        string propAlias = Model.MacroParameters["PropertyAlias"].ToString();
    
    }
    test: @propAlias
    

    If the macro is placed in a 'regular' node (using the RTE) it executes as expected and the parameter is passed. However, I'd also like to call the macro from code as follows:

    Dim mcr As New umbraco.presentation.templateControls.Macro()
         mcr.Alias = strInsertValue       
         mcr.MacroAttributes.Add("PropertyAlias", "lessonticketprice")
         mcr.RenderControl(writer)
    

    In this case no parameter is passed and the output is only 'test:'

    Is the 'Model' available in this context? If not, what should I use to get the parameter?

    Thanks, Steve

Please Sign in or register to post replies

Write your reply to:

Draft