Copied to clipboard

Flag this post as spam?

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


  • Tom Krzesinski Jr 3 posts 73 karma points
    Dec 02, 2015 @ 22:23
    Tom Krzesinski Jr
    0

    Error loading Partial View script

    Hello I am getting this error when loading my navigation script. Error loading Partial View script. Bellow is the script I an using. I do think it has something to do with using NodeByID but I am not sure and did not build the site original. I have copied the site from a very old umbraco version to a new version with win host and this seem to be my only hang up any help is appreciated. Thanks, Tommy

    @{
        var HowWeHelpNode = Model.NodeById(1137);       
    }
    
    <div class="grid_3 alpha equalColumn">
        <div class="side-nav">
            <ul>
                @if(Model.Id == 1137)
                {
                    <li class="active"><a href="/how-we-help.aspx">How We Help</a></li>
                }
                else
                {
                    <li><a href="/how-we-help.aspx">How We Help</a></li>
                }
    
                @foreach(var child in HowWeHelpNode.Children){
    
                    if(Model.Id == child.Id)
                    {
                        <li class="active"><a href="@child.Url">@child.Name</a></li>
                    }
                    else
                    {
                        <li><a href="@child.Url">@child.Name</a></li>
                    }
    
                }
            </ul>
        </div>
    <!-- /grid_3 --></div>
    
  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 04, 2015 @ 23:59
    Dennis Aaen
    0

    Hi Tom,

    If you are using Umbraco 7 you will have to make some changes to the code to get it work. Instead of @Model, you will need to use @CurrentPage, since you are using the dynamic Razor syntax.

    Another thing you need to change is the Model.NodeById, in Umbraco 7, it becomes Umbraco.Content(1137) https://our.umbraco.org/documentation/Reference/Templating/Mvc/views and https://our.umbraco.org/documentation/Reference/Querying/UmbracoHelper/

    I have updated your code, so try this code below.

    @{
        var HowWeHelpNode = Umbraco.Content(1137);       
    }
    
    <div class="grid_3 alpha equalColumn">
        <div class="side-nav">
            <ul>
                @if(CurrentPage.Id == 1137)
                {
                    <li class="active"><a href="/how-we-help.aspx">How We Help</a></li>
                }
                else
                {
                    <li><a href="/how-we-help.aspx">How We Help</a></li>
                }
    
                @foreach(var child in HowWeHelpNode.Children){
    
                    if(CurrentPage.Id == child.Id)
                    {
                        <li class="active"><a href="@child.Url">@child.Name</a></li>
                    }
                    else
                    {
                        <li><a href="@child.Url">@child.Name</a></li>
                    }
    
                }
            </ul>
        </div>
    <!-- /grid_3 --></div>
    

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft