Copied to clipboard

Flag this post as spam?

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


  • sim0n20 7 posts 27 karma points
    Jun 10, 2011 @ 16:31
    sim0n20
    0

    Session variable in macro

    Hi everyone,

    Is it possible to pass a session variable into a macro as a parameter?

    Thanks

     

    Simon

     

  • Steven Newstead 62 posts 103 karma points
    Jun 13, 2011 @ 15:58
    Steven Newstead
    0

    Something like this should work as long as you have added the extra parameter on the macro in Umbraco:

             <umbraco:Macro ID="Macro2" Test="<%Session["myVariable"].ToString(); %>"  runat="server">

            </umbraco:Macro>

     

    Alterntatively you can also get fields from the node that is rendering if you do something like this:

             <umbraco:Macro ID="Macro2" ToEmail="#[email]"   runat="server">

            </umbraco:Macro>

     

     

    So in this example I have an Event master page and an Event macro which has an extra parameter called ToEmail and as the event node is being rendered the Umbraco checks the node for a field called 'email' and passes it into the macro.

     

     

     

     

     

     

  • Francois Payette 1 post 21 karma points
    Oct 07, 2011 @ 19:19
    Francois Payette
    0

    Hello, 

     

    <umbraco:Macro ID="Macro2" Test="<%Session["myVariable"].ToString(); %>"  runat="server">

            </umbraco:Macro>

    Does not work.



    Parser Error Message: Server tags cannot contain <% ... %> constructs.

    Anybody has a suggestion how to pass a session variable into an umbraco macro?

     

    TIA,

    F

Please Sign in or register to post replies

Write your reply to:

Draft