Copied to clipboard

Flag this post as spam?

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


  • Ryan 35 posts 129 karma points
    Mar 08, 2013 @ 16:47
    Ryan
    0

    Macro with .net usercontrol does not render on page

    Sorry if this is in the wrong section.

    I created a macro with a .net usercontrol (and code behind), dll and sql connection string in Umbraco v6.0.  Files and connection string are added to the filesystem and web.config.  I would like to be able to add the macro to a page within the editor.  When I add it to a page, it renders in the editor and looks as expected.  However, when I publish the page, it is not there?  No error and nothing in the source.  The published page still shows the macro rendered correctly in the backoffice.

    Oddly, if I add the macro directly to a template, it renders fine.  I'm not sure why the macro will not publish from the editor.  Caching is set to 0, yes for cache by page.  I'm using Umbraco 6.0 with MVC.  Any thoughts?

    Please let me know if you need more information.  Thanks for the help.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 10, 2013 @ 12:30
    Jan Skovgaard
    0

    Hi Ryan

    If you want your user control to work as expected you will need to run webforms instead of MVC. You can have the usercontrol render but it won't do anything when different events are triggered.

    Therefore you should probably consider refacoring it to a Razor view instead.

    Hope this helps.

    /Jan

  • Ryan 35 posts 129 karma points
    Mar 12, 2013 @ 17:15
    Ryan
    0

    Hi Jan

    Thanks for the reply.  Just to confirm, does this mean all existing usercontrols with .net code behind will not work in Umbraco with MVC?

    If I were to switch back to webforms, I would need to update the templates.  I'm using my partial views like includes, so I would likely switch them to razor macros and toss them in the pages/templates as needed.  Are there any other concerns switching back to webforms, aside from rewriting some of the razor in the views?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Mar 12, 2013 @ 19:28
    Jan Skovgaard
    0

    Hi Ryan

    If your user controls conatins any form elements that are supposed to do something on different events like page_load etc. then they won't work. If you're just using the nodefactory to display some data (no interaction) then it will work fine.

    I don't see what the pitfalls would be apart from those you have mentioned yourself. There will have to be some code refactoring but the data structure etc. will not be changed. However I have not done this before so there might be things that I overlook.

    Hope this helps.

Please Sign in or register to post replies

Write your reply to:

Draft