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