is it possible to use views that inherits the UmbracoViewPage with master views which inherits the UmbracoTemplatePage?
Tried to make a custom controller and a custom model to work with in a view. But when using a master view it says that it founds my custom model instead of the RenderModel Umbraco provides.
I think thats because the master view only uses the UmbracoTemplatePage.
For now i derived my custom model from the RenderModel but i don't need the content stuff and everything else in my custom model.
I know that it works with surface controllers but I just want to use the normal controllers and not call Html.Action for rendering a partial with a surface controller.
Hi, i have had the same sort of thing. You can inherit using @inherits Umbraco.Web.Mvc.UmbracoViewPage<YourCustomModel> and then passing in a new instance of your custom model in the view.
The problem i had was i could not get access to the current page in a current view so have had to create a ID property in my
custom model set the property in the View and then use that id to get the node in the partial.
I used the @inherits Umbraco.Web.Mvc.UmbracoViewPage<YourCustomModel> in my view and in the controller I returned: return CurrentTemplate(new YourCustomModel());
In the master view of this view i had @inherits Umbraco.Web.Mvc.UmbracoTemplatePage.
As i called the url of that node (frontend) i became an error which states that "YourCustomModel" was found and he wants "RenderModel".
UmbracoViewPage error with master views
Hey all,
is it possible to use views that inherits the UmbracoViewPage with master views which inherits the UmbracoTemplatePage?
Tried to make a custom controller and a custom model to work with in a view. But when using a master view it says that it founds my custom model instead of the RenderModel Umbraco provides.
I think thats because the master view only uses the UmbracoTemplatePage.
For now i derived my custom model from the RenderModel but i don't need the content stuff and everything else in my custom model.
I know that it works with surface controllers but I just want to use the normal controllers and not call Html.Action for rendering a partial with a surface controller.
Hope it makes sense. ;)
Hi David
Do you get an error message or is the preview simply not working?
Perhaps this should be reported as a bug on the issue tracker here issues.umbraco.org/issues/U4
/Jan
Hi, i have had the same sort of thing. You can inherit using @inherits Umbraco.Web.Mvc.UmbracoViewPage<YourCustomModel> and then passing in a new instance of your custom model in the view.
The problem i had was i could not get access to the current page in a current view so have had to create a ID property in my
custom model set the property in the View and then use that id to get the node in the partial.
Hope that helps.
Charlie :).
Thanks for the help so far.
I used the @inherits Umbraco.Web.Mvc.UmbracoViewPage<YourCustomModel> in my view and in the controller I returned: return CurrentTemplate(new YourCustomModel());
In the master view of this view i had @inherits Umbraco.Web.Mvc.UmbracoTemplatePage.
As i called the url of that node (frontend) i became an error which states that "YourCustomModel" was found and he wants "RenderModel".
Try returning a partial view instead of the CurrentTemplate:
return PartialView("_yourView", model)
yea you need to return a PartialView result from your controller action :)
Hey all,
thanks for the help.
Will try to return a partial and see if it works.
David, did you manage to get it to work? :) Charlie :)
Sadly i hadn't time for this in the last days. Hopefully i can try it out today.
Will post my results then.
So just to post my results.
I made a little test with returning a partialview and not a view and it works in my little test.
So thanks for the help!
No problem :)
is working on a reply...