Copied to clipboard

Flag this post as spam?

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


  • Corey Sherman 55 posts 127 karma points
    Apr 21, 2014 @ 21:56
    Corey Sherman
    0

    Trouble with using a UserControl in Umbraco 7

    I wrote a usercontrol for Umbraco that is just a basic, configurable Contact Form, through a Macro complete with parameters. The problem I am having is that the usercontrol isn't rendering at all when I use it in a template. The page in question loads without error and none of the markup from the control is rendered on the page at all. I even added some debugging messages using log4net in the control, and none of those messages make it to the logs; the page just loads like the control isn't even there. This same control used to work back in Umbraco 6 and the only real changes I made were to update the references to Umbraco 7. Is there something I'm doing wrong? 

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 22, 2014 @ 09:11
    Jan Skovgaard
    1

    Hi Corey

    By default Umbraco is running in MVC mode and therefore your user control is probably not working. You can however try changing it to run webforms by having a look at it in the /config/umbracoSettings.config and go to the

    But before doing so please make a backup of your files since I can't remember what that does to the templates since templates are switched from views to masterpages.

    Hope this helps.

    /Jan

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Apr 22, 2014 @ 09:28
    Sebastiaan Janssen
    2

    It does nothing except that when you create new templates they will be masterpages instead of views.

    And yes, usercontrols cannot run in an MVC view, so you'd need to have a master page for that. It's also pretty easy to port your usercontrol to a surfacecontroller, we don't recommend mixing views and masterpages, for an example see: https://umbraco.com/follow-us/blog-archive/2013/7/14/moving-from-webforms-to-mvc.aspx

  • Corey Sherman 55 posts 127 karma points
    Apr 22, 2014 @ 15:30
    Corey Sherman
    0

    Thanks for the feedback.

    I hope this information helps others in the future. I remembered changing over to WebForms in the umbracoSettings.config, but regrettably I discovered very early this morning that the problem was a user error with my Macro call in the template... I certainly need to get away from WebForms ASAP and will check out SurfaceControllers in the near future.

Please Sign in or register to post replies

Write your reply to:

Draft