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?
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.
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.
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?
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
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
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.
is working on a reply...