Copied to clipboard

Flag this post as spam?

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


  • Dan Sørensen 102 posts 327 karma points
    Dec 09, 2013 @ 15:14
    Dan Sørensen
    0

    Error saving scripting files

    I was trying to save this simple navigation

    <nav>
    <ul>
    @{ var homeNode = Model.AncestorOrSelf("Home");}
      <li>
                <a href="@homeNode.Url">@homeNode.Name</a>
            </li>
        @foreach (var page in homeNode.Children.Where("Visible"))
        { 
            <li>
                <a href="@page.Url">@page.Name</a>
            </li>
    }
    </ul>
    @if (page.Children.Where("Visible").Count() > 0)
    {
    <ul>
    @foreach (var childPage in page.Children.Where("Visible"))
    {
    <li><a href="@childPage.Url">@childPage.Name</a></li>
    }
    </ul>
    }
    </ul>
    </nav>

    But i got this error 

    Saving scripting file failed: d:\_produktion\techcollege.dk\MacroScripts\635221987629512119_Navigation.cshtml(40): error CS0135: 'page' conflicts with the declaration 'umbraco.page'

  • Per Ploug 865 posts 3491 karma points MVP admin
    Dec 09, 2013 @ 15:55
    Per Ploug
    0

    Your code:

    @if (page.Children.Where("Visible").Count() > 0)
    

    Is outside of the foreach loop that sets the page variable, which is why you get this error

  • Dan Sørensen 102 posts 327 karma points
    Dec 09, 2013 @ 16:58
    Dan Sørensen
    0

    thaks silly me !

Please Sign in or register to post replies

Write your reply to:

Draft