Copied to clipboard

Flag this post as spam?

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


  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Sep 02, 2010 @ 10:23
    Ali Sheikh Taheri
    0

    how to call a macro within c# ?

    I would like to call an XSLT macro inside c# and save the result into a string.

    Any idea on this?

    Thank

    Ali

  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Sep 02, 2010 @ 10:26
    Ali Sheikh Taheri
    1

    I have also tested following code , but didnt work.

    string temp = umbraco.library.RenderMacroContent("<umbraco:Macro pId=\"" + myNode.Id + "\" Alias=\"Get_Items_1st_Level\" runat=\"server\"></umbraco:Macro>", myNode.Id);
  • Steen Tøttrup 191 posts 291 karma points c-trib
    Sep 02, 2010 @ 10:55
    Steen Tøttrup
    0

    When doing it from C# you should probably try using the macro class (umbraco.macro) instead of the umbraco.library.

    I haven't tried it myself, but take a look, it has a bunch of methods, one of them might be the one you're looking for!

     

  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Sep 02, 2010 @ 13:11
    Ali Sheikh Taheri
    0

    thanks Steen for your reply. I had a look but couldn't figure out.

    is there any documentation for it as I couldn't find any. 

    Cheers

    Ali

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 02, 2010 @ 13:37
    Jonas Eriksson
    1

    Hi, umbraco library RenderMacroContent use old macro syntax, so this should work better:

    See http://en.wikibooks.org/wiki/Umbraco/Reference/umbraco.library/RenderMacroContent

    HTH / Jonas

    (Still is that syntax in 4.5.2)

  • Ali Sheikh Taheri 470 posts 1648 karma points c-trib
    Sep 02, 2010 @ 13:50
    Ali Sheikh Taheri
    0

    You are legend Jonas.

    Thanks a lot mate , it works like a charm.

    Cheers

    Ali

  • Jonas Eriksson 930 posts 1825 karma points
    Sep 02, 2010 @ 13:53
    Jonas Eriksson
    0

    :-) Cheers!

  • TimNape 12 posts 32 karma points
    May 24, 2011 @ 19:29
    TimNape
    0

    @jonas

    After + 6 hours of struggling with this and trying may ways including the

    umbraco.presentation.templateControls.Macro

    Thanks Jonas - ur a star

Please Sign in or register to post replies

Write your reply to:

Draft