Copied to clipboard

Flag this post as spam?

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


  • Timsn 121 posts 231 karma points
    Jul 12, 2009 @ 17:33
    Timsn
    1

    RenderMacroContent problem

    I want to render a usercontrol within my xslt. So I tried:

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;MyMacro&quot; &gt; &lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes"/>

    My macro gets rendered (I can see my form) but it seems that no codebehind is executed. Neither in Page_Load nor in OnPreRender.
    When I render this macro within a template, everything works as expected.

    I also tried to use the new syntax to include my macro like I did in my template:

    &lt;umbraco:Macro Alias=&quot;MyMacro&quot; runat=&quot;server&quot;&gt;&lt;/umbraco:Macro&gt;

    But with no success - nothing is displayed in this case.

    The only reference to RenderMacroContent I found was this wiki page. Maybe it's outdated.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 12, 2009 @ 17:37
    Sebastiaan Janssen
    1

    I think you might be missing a form with property runat="server" around the macro.. That would cause the usercontrol to just render the HTML, but the functionality will never be executed.

  • Timsn 121 posts 231 karma points
    Jul 12, 2009 @ 17:53
    Timsn
    0

    You're right, I missed it. Now I tried:

    <xsl:value-of select="umbraco.library:RenderMacroContent('&lt;?UMBRACO_MACRO macroAlias=&quot;IssueTrackerAddForm&quot; runat=&quot;server&quot; &gt; &lt;/?UMBRACO_MACRO&gt;', $currentPage/@id)" disable-output-escaping="yes"/>

    But nothing changes. Still the same problem.

    Another strange thing is that my form validators are showing the errormessage when the page is rendered. Normally they are shown after I submit my form and missed a field...
    Also this problem does not exists when I include this macro in my template.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 12, 2009 @ 17:56
    Morten Bock
    1

    You cannot run a usercontrol macro inside xslt. It is not supported.

    I don't know the exact technical reason, but as you corretly write, the codebehind will not be registered because the output from XSLT is simply a string, and not a .net template.

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 12, 2009 @ 17:57
    Morten Bock
    101

    Also, as you can see, the method is only called RenderMacroContent, which is actually what it does. It just renders the output, and does not register any logic behind it.

  • Timsn 121 posts 231 karma points
    Jul 12, 2009 @ 18:23
    Timsn
    0

    I see, that is obvious. I'll try to find another solution for my problem.

    Thank you.

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jul 13, 2009 @ 05:56
    Sebastiaan Janssen
    0

    Aha! That's good to know Morten. I try to prevent using macro's from XSLT anyway, it's kinda ugly.

  • Jonas Høiby 62 posts 53 karma points
    Jan 13, 2010 @ 14:05
    Jonas Høiby
    0

    im having the same problem .. what could it be? it must be some kind of settings or environment thing ..

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jan 13, 2010 @ 19:03
    Morten Bock
    0

    I don't know if it is possible to solve it, but it will not work in the current version of umbraco. I am guessing that it has something to do with the time when the xstl macros are rendered. Until the xslt is rendered, the asp.net runtime knows nothing about the usercontrol you are inserting, and if the usercontrol rendering has already completed, then it will never be picked up.

Please Sign in or register to post replies

Write your reply to:

Draft