Copied to clipboard

Flag this post as spam?

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


  • MuirisOG 382 posts 1284 karma points
    Apr 12, 2017 @ 10:47
    MuirisOG
    0

    .NET Templated Controls (e.g. repeaters) in Page Content

    Hi everyone

    I'm on v752, using Webforms, and I have some templated .NET controls (i.e. repeaters) embedded in page content (they're coming from our old CMS).

    I can see here that this might be a non-starter in Umbraco from this page: https://our.umbraco.org/forum/developers/api-questions/6253-Custom-Controls-using-ITemplate

    I have (finally, with a lot of pain and getting stuck into TinyMCE), found a way to get this to work in Umbraco, but it is definitely not an elegant solution. It involves making a macro with a parameter for the entire repeater template, which is parsed in code behind using the link here as guidance: https://msdn.microsoft.com/en-us/library/0e39s2ck.aspx

    What I would like to know is how Umbraco does its magic with macros that point to usercontrols in page content, and, more to the point, would it help me?

    Any help would be appreciated.

  • MuirisOG 382 posts 1284 karma points
    Apr 13, 2017 @ 10:40
    MuirisOG
    0

    PS This was my original post but as I had no replies, I thought it must have been badly worded. https://our.umbraco.org/forum/using-umbraco-and-getting-started/85007-rte

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Apr 13, 2017 @ 11:11
    Dan Diplo
    0

    You can add existing user controls quite simply (though it's no longer the preferred way). I've not done this for a long time, but you should be able to do it this way:

    Go to Developer tree > Macros > Create

    Once created a macro go to Macro Properties and in the section called CHOOSE A FILE TO RENDER then select your user control from the list (it needs to be in your website). You can then go to parameters to map any parameters.

    See https://our.umbraco.org/documentation/reference/templating/macros/

    Again, haven't used them for a long time, but they should still work.

  • MuirisOG 382 posts 1284 karma points
    Apr 13, 2017 @ 12:14
    MuirisOG
    0

    Thanks Dan,

    yes, this method does work.

    However, as it is a repeater, the templates have been specified in the page content (as they can be rendered differently throughout the site).

    It's that bit that has me stumped, because I can't add the headertemplate, itemtemplate or footertemplate to the page content. I had created a parameter to house the entire repeater control, and the Microsoft link in my first post was helping me render them correctly. In my previous CMS, I could add the entire usercontrol, including templates (without the need for a macro).

    In any case, I need to rewrite these old controls, which I was hoping to put off, as they appear in quite a few places.

Please Sign in or register to post replies

Write your reply to:

Draft