Copied to clipboard

Flag this post as spam?

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


  • Uchenna 9 posts 79 karma points
    May 24, 2018 @ 11:25
    Uchenna
    0

    Render Macros with Controller actions

    I understand that marcos are reusable components and I think they're great. From my understanding, macros are setup by pointing to a HTML file which can read the macros paramters and use that to display content.

    However, is it possible for the macros to render a controller action result instead? Let's say I have a controller called WidgetsController, and I wanted my macros to render and return the HTML of the ContentCard Action result?

    I want to be able to execute custom code from a controller action, so for example I can call an API to get a set of results that would be used as data for my macros view.

  • pranjal 75 posts 188 karma points
    May 28, 2018 @ 12:53
    pranjal
    0

    Use this to render macro in controller action

    umbraco.library.RenderMacroContent(src.BodyText, src.Id)

  • pranjal 75 posts 188 karma points
    May 28, 2018 @ 12:54
    pranjal
    0

    @inherits Umbraco.Web.Macros.PartialViewMacroPage

    @Html.Action("ShowRequestCallBackForm", "ContactFormsSurface")

Please Sign in or register to post replies

Write your reply to:

Draft