Copied to clipboard

Flag this post as spam?

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


  • Nick 84 posts 451 karma points
    Mar 04, 2017 @ 08:05
    Nick
    0

    Error loading Partial View script

    Morning All, Another day another Umbraco problem I am having, hopefully somebody could help me, I am currently upgrading a current Umbraco site from v6 to v7.5.5, and changing a lot of my macroscripts to partials. Having particlular trouble with my homepage banner carousel getting an error on the Partial view script not loading, here is the partial view for the homepage, I've embedded within the homepage template via a Macro with a content picker with alias nodeId which dynamically pulls in an image from a separate folder

    Here is the partial view script:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage   
    
    @if (Model.MacroParameters["startNodeID"] != null)
    {
    @* Get the start node as a dynamic node *@
    var startNodeID =       Umbraco.Content(Model.MacroParameters["startNodeID"]);
    
    if (startNodeID.Children.Where("Visible").Any())
    {
        <ul class='sequence-canvas'>
            @foreach (var page in startNodeID.Children.Where("Visible"))
            { 
                <li class='frame static'>
    
                        @if (CurrentPage.HasValue("slideImage")) {
                            var slideImage = Umbraco.Media(@CurrentPage.slideImage);
                            <div class='bg' style='background-image: -webkit-repeating-linear-gradient(135deg, rgba(0,0,0,.3), rgba(0,0,0,.3) 1px, transparent 2px, transparent 2px, rgba(0,0,0,.3) 3px), url(@slideImage.Url)'></div>
    
                        }
    
                 <div class='small-title bottom-to-top'>
                        <div class='row'>
                          <div class='large-12 columns'>
                            <h2>The perfect theme for</h2>
                          </div>
                        </div>
                      </div>
                      <div class='title bottom-to-top'>
                        <div class='row'>
                          <div class='large-12 columns'>
                            <h2>Many purposes</h2>
                          </div>
                        </div>
                      </div>
                      <div class='buttons-wrapper bottom-to-top'>
                        <div class='row'>
                          <div class='large-12 columns'>
                            <div class='two spacing'></div>
                            <a class='button' href='http://themeforest.net/user/honryou/portfolio?ref=honryou'>Learn More</a>
                          </div>
                        </div>
                      </div>
                    </li>
                 }
    
    
        </ul>
    }    
     }
    

    Also this is the full error message within the log files:

    Error loading Partial View (file: ~/Views/MacroPartials/HeroBanner.cshtml). Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.getItem(TKey key) at ASP.PageViewsMacroPartialsHeroBannercshtml.Execute()

    Any help would be much appreciated.

    Kind regards

    Nick

  • Stefano 61 posts 313 karma points c-trib
    Mar 05, 2017 @ 10:22
    Stefano
    100

    Have you tried ContainsKey on your first if confition?

    Eg

    @if (Model.MacroParameters.ContainsKey("startNodeID")
        && Model.MacroParameters["startNodeID"] != null)
    
  • Nick 84 posts 451 karma points
    Mar 06, 2017 @ 10:03
    Nick
    1

    Many thanks Stefano, that did the trick, have a great day.

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft