Copied to clipboard

Flag this post as spam?

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


  • Haansi 51 posts 150 karma points
    Sep 22, 2014 @ 04:36
    Haansi
    0

    Nested layout pages and RenderBody()

    I have nested templates. My _Basic templates has @RenderBody() and similary my Child template also has @RenderBody()

    I don't want to use _Basic tmeplates as layout for views. I understand multiple @Section can be defined in a layouts but why I cant use @RenderBody() in both parent and child layout as well.

    If I m not wrong it is allowed in Razor but why I can't do it in Razor with Umbraco. I tried and was getting the following error:

    The "RenderBody" method has not been called for layout page "~/Views/Child.cshtml".
    
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 22, 2014 @ 08:10
    Dennis Aaen
    0

    Hi Haansi,

    I think that you should try to see this video chapter about templates, they are explain the @RenderBody() http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/advanced-master-templates/

    Maybe this blogpost from Umbraco can help you too. http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx and http://our.umbraco.org/documentation/cheatsheets/masterpagestoviews#Contentplaceholder

    Hope this helps,

    /Dennis

  • Haansi 51 posts 150 karma points
    Sep 23, 2014 @ 01:25
    Haansi
    0

    Thanks Dennis, I have checked these resources but still I have question. Why in Umbraco I can't use template with @RenderBody() directly in a Content ? Kindly guide.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 23, 2014 @ 08:17
    Dennis Aaen
    0

    Hi Haansi.

    You can compare the RenderBody() with the the ContentPlaceHolder in master page. A layout page can have only one RenderBody method.

    Try to see this article: http://www.dotnet-tricks.com/Tutorial/mvc/9Ya6290314-Layouts,-RenderBody,-RenderSection-and-RenderPage-in-ASP.NET-MVC.html

    Hope this helps,

    /Dennis

  • Gavin Harriss 15 posts 33 karma points
    Apr 12, 2016 @ 22:36
    Gavin Harriss
    0

    For anyone else that comes across this issue, I found the answer provided a bit more directly here - http://stackoverflow.com/a/8579238/250254

  • 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