Copied to clipboard

Flag this post as spam?

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


  • Nathan Reece 62 posts 376 karma points
    Jul 20, 2020 @ 08:38
    Nathan Reece
    0

    How do i render a partial View to screen in Umbraco 8?

    I have created a partial view in the Umbraco back office, but i am struggling with the code on how to render it to my templates.

    Can anyone help me out!?

    I am using Umbraco 8, Not Sure if this makes the process any different.

  • David Armitage 505 posts 2073 karma points
    Jul 20, 2020 @ 08:53
    David Armitage
    100

    Hi Nathan,

    There is two ways of rendering a partial view on a template.

    Actually this is just standard MVC so not so much Umbraco specific.

    Here is an example of two ways to do it. My partial view is called TopMenu.

    @Html.Partial("TopMenu")
    

    Quick and easy way.

    @Html.Partial("~/Views/Partials/TopMenu.cshtml")
    

    Sometimes I prefer to do it like this. A little more code but with bigger projects I like to store my partial views in different folders to keep things neat. This also helps other developers when I am working in a team.

    Hope this helps.

    Regards

    David

  • Nathan Reece 62 posts 376 karma points
    Jul 20, 2020 @ 08:54
    Nathan Reece
    0

    Thanks Dave, Ill test the quick and easy way now.

  • Nathan Reece 62 posts 376 karma points
    Jul 20, 2020 @ 09:16
    Nathan Reece
    2

    Cheers David, I've Got it now.

    For anyone else struggling with creating and rendering Partial Views, I have Written a Blog Step by Step Tutorial on how it is done.

    Here's the link: https://www.umbrajobs.com/blog/posts/2020/july/how-to-create-and-render-a-partial-view-to-a-template-in-umbraco-8/

Please Sign in or register to post replies

Write your reply to:

Draft