Copied to clipboard

Flag this post as spam?

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


  • David Brendel 786 posts 2949 karma points c-trib
    Mar 14, 2013 @ 13:55
    David Brendel
    0

    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. ;)

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Mar 15, 2013 @ 01:39
    Jan Skovgaard
    0

    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

  • Charles Afford 1163 posts 1709 karma points
    Mar 15, 2013 @ 10:09
    Charles Afford
    0

    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 :).

  • David Brendel 786 posts 2949 karma points c-trib
    Mar 15, 2013 @ 13:02
    David Brendel
    0

    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".

  • Andreas Iseli 150 posts 427 karma points
    Mar 15, 2013 @ 16:34
    Andreas Iseli
    100

    Try returning a partial view instead of the CurrentTemplate:

    return PartialView("_yourView", model)

  • Charles Afford 1163 posts 1709 karma points
    Mar 16, 2013 @ 10:38
    Charles Afford
    1

    yea you need to return a PartialView result from your controller action :)

  • David Brendel 786 posts 2949 karma points c-trib
    Mar 18, 2013 @ 09:06
    David Brendel
    0

    Hey all,

    thanks for the help.

    Will try to return a partial and see if it works.

  • Charles Afford 1163 posts 1709 karma points
    Mar 19, 2013 @ 21:22
    Charles Afford
    0

    David, did you manage to get it to work?  :)  Charlie :)

  • David Brendel 786 posts 2949 karma points c-trib
    Mar 21, 2013 @ 09:06
    David Brendel
    0

    Sadly i hadn't time for this in the last days. Hopefully i can try it out today.

    Will post my results then.

  • David Brendel 786 posts 2949 karma points c-trib
    Mar 22, 2013 @ 17:00
    David Brendel
    0

    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!

  • Charles Afford 1163 posts 1709 karma points
    Mar 30, 2013 @ 13:23
    Charles Afford
    0

    No problem :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies