Embedding an MVC form inside the old master template architecture
Hi there, I have an old Umbraco web application which was upgraded to v6 earlier this year.
It uses .NET ascx user controls and your standard .master pages as you'd expect.
I now need to create a brand new page which is essentially a booking form for an event.
I'd like to create it using MVC, as I do everything with MVC nowadays. I don't really want to duplicate the page layout / the frame. Is it possible to embed an MVC partial view inside the old master templates?
Is there a tutorial or standard way to do this? I've found pieces of code but nothing complete. Right now I seem to be getting an error when I add the model to my view. It's hard to debug when Umbraco just shows "Error loading Partial View script ..."
If I understand your questions correctly then you have an old user control that you want to use in your MVC Umbraco site.
Try to go to the developer section --> Macros, in there create a new macro. After this you can point a Razor, XSLT file or a Usercontrol. Try to see the screenshot here.
To be able to choose the usercontrol it needs to be located in the usercontrol folder in your Umbraco installation file system.
Dennis, not exactly. I know how to do the macro part. I can create a .cshtml partial view and get that to work just fine. Now, I want to hook a model to my view so I can create strongly typed fields on my form. As soon as I add the model reference to the top of the view, it breaks.
I tried
@inherits Umbraco.Web.Mvc.UmbracoViewPage
and both break the view: Error loading Partial View script (file: ~/Views/MacroPartials/Admin/Ethics/Opinions.cshtml)
Embedding an MVC form inside the old master template architecture
Hi there, I have an old Umbraco web application which was upgraded to v6 earlier this year.
It uses .NET ascx user controls and your standard .master pages as you'd expect.
I now need to create a brand new page which is essentially a booking form for an event.
I'd like to create it using MVC, as I do everything with MVC nowadays. I don't really want to duplicate the page layout / the frame. Is it possible to embed an MVC partial view inside the old master templates?
thanks
Kris
Similar issue here. Did you figure out a solution?
Hello,
Yes it's possible to use a Partial View Macro and embed that Marco on your .master page.
Jeroen
Is there a tutorial or standard way to do this? I've found pieces of code but nothing complete. Right now I seem to be getting an error when I add the model to my view. It's hard to debug when Umbraco just shows "Error loading Partial View script ..."
Hi Connie,
If I understand your questions correctly then you have an old user control that you want to use in your MVC Umbraco site.
Try to go to the developer section --> Macros, in there create a new macro. After this you can point a Razor, XSLT file or a Usercontrol. Try to see the screenshot here.
To be able to choose the usercontrol it needs to be located in the usercontrol folder in your Umbraco installation file system.
Hope this helps,
/Dennis
If you want more info about the error try adding umbDebugShowTrace=true to as a querystring to the url: https://our.umbraco.org/wiki/how-tos.
Jeroen
Tracing is not working, apparently does not work in Umbraco 6.1.x per the referenced link.
Dennis, not exactly. I know how to do the macro part. I can create a .cshtml partial view and get that to work just fine. Now, I want to hook a model to my view so I can create strongly typed fields on my form. As soon as I add the model reference to the top of the view, it breaks.
I tried @inherits Umbraco.Web.Mvc.UmbracoViewPage
and both break the view: Error loading Partial View script (file: ~/Views/MacroPartials/Admin/Ethics/Opinions.cshtml)
Could you post the Razor code of the macro and also a screenshot of how you configured the macro in the backoffice?
Jeroen
is working on a reply...