Copied to clipboard

Flag this post as spam?

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


  • Tilly 3 posts 23 karma points
    Oct 07, 2010 @ 04:15
    Tilly
    0

    load an XSLT macro from a .NET control

    hi all,

    is it possible to load an XSLT macro from a .net CONTROL?

    I have a situation where there is a page with about 6 components on it. 4 of these 6 can be done with XSLT. the other 2 need to be .NET. Whats the best way to go about doing this? i can always just load 6 individual macros from the template itself, is that advisable?

    Thanks,

    Tilly

  • Jonathan Cohen 40 posts 115 karma points
    Oct 07, 2010 @ 07:50
    Jonathan Cohen
    0

    Hi, am not sure if this is what you want to do, but this code I use to load a macro in .NET.
    The Macro we load is on a Document Type, and use the macro picker datatype (http://our.umbraco.org/projects/backoffice-extensions/macropicker)

    using umbraco.presentation.templateControls; // need this for Item
    Item macro = new Item
    {
        NodeId = myNode.Id.ToString(),  // then node id of node containg the macro 
        Field = "macro"         // the property field of the macro
    };
    if (macro != null)     
        myPlaceHolder.Controls.Add(macro);  // add the item to a placeholder

    I have stripped away some code, but this should do it, eventually you want to check if more things exists and some other error checks.

    But we also load lots of indiviudal macros in each template and that should not be a problem.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 07, 2010 @ 14:01
    Aaron Powell
    0

    Macros are standard ASP.NET server controls, so you can add and remove them programmatically.

    Setting the appropriate alias will indicate what one you want to load and where.

Please Sign in or register to post replies

Write your reply to:

Draft