Copied to clipboard

Flag this post as spam?

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


  • Noor Alam 26 posts 97 karma points
    Sep 02, 2019 @ 19:35
    Noor Alam
    0

    RuntimeBinderException: 'object' does not contain a definition for 'Where'

    Hi,

    During implementation of following method for Creating Dynamic Navigation Menu using Umbarco V8 -- Getting attached error so please suggest . Thanks and waiting response from experts....

    enter image description here

    ===============================================

     private List NavigationListItem GetChildNavigationList(dynamic page)
            {
                ListNavigationListItem listItems = null;
                **var childPages = page.Children.Where("Visible");**
                if (childPages != null && childPages.Any() && childPages.Count() > 0)
                {
                    listItems = new ListNavigationListItem();
                    foreach (var childPage in childPages)
                    {
                        NavigationListItem listItem = new NavigationListItem(new NavigationLink(childPage.Url, childPage.Name));
                        listItem.Items = GetChildNavigationList(childPage);
                        listItems.Add(listItem);
                    }
                }
                return listItems;
            }
    
  • Alex Skrypnyk 5347 posts 19753 karma points MVP 3x admin c-trib
    Sep 02, 2019 @ 20:31
    Alex Skrypnyk
    0

    Hi Noor

    Do not use dynamic type

    Alex

  • Noor Alam 26 posts 97 karma points
    Sep 02, 2019 @ 21:52
    Noor Alam
    0

    Thanks Alex,

    Then which data type needs to be use inested of dynamic kindly suggest.

  • Alex Skrypnyk 5347 posts 19753 karma points MVP 3x admin c-trib
    Sep 02, 2019 @ 21:55
    Alex Skrypnyk
    0

    Try to use IPublishedContent

    And this is not datatype

  • Noor Alam 26 posts 97 karma points
    Sep 02, 2019 @ 21:58
    Noor Alam
    0

    Not getting where i need to use "IPubloshedContent"

  • Alex Skrypnyk 5347 posts 19753 karma points MVP 3x admin c-trib
    Sep 02, 2019 @ 22:04
    Alex Skrypnyk
    100

    Your code would be better like this:

    private List<NavigationListItem> GetChildNavigationList(IPublishedContent page)
            {
                ListNavigationListItem listItems = null;
                var childPages = page.Children.Where(x => x.IsVisible()); 
                if (childPages != null && childPages.Any() && childPages.Count() > 0)
                {
                    listItems = new ListNavigationListItem();
                    foreach (var childPage in childPages)
                    {
                        NavigationListItem listItem = new NavigationListItem(new NavigationLink(childPage.Url, childPage.Name));
                        listItem.Items = GetChildNavigationList(childPage);
                        listItems.Add(listItem);
                    }
                }
                return listItems;
            }
    
  • Noor Alam 26 posts 97 karma points
    Sep 02, 2019 @ 22:08
    Noor Alam
    1

    Great Alex.......... Thanks Working now.

  • Noor Alam 26 posts 97 karma points
    Sep 02, 2019 @ 22:11
    Noor Alam
    0

    Alex ...Can you please help for below issue ... please suggest solution...

    https://our.umbraco.com/forum/umbraco-8/98846-umbraco-does-not-exist-in-the-current-context#comment-311374

  • Alex Skrypnyk 5347 posts 19753 karma points MVP 3x admin c-trib
    Sep 02, 2019 @ 22:21
    Alex Skrypnyk
    0

    It's midnight at my place, I will have a look tomorrow.

  • Noor Alam 26 posts 97 karma points
    Sep 02, 2019 @ 22:24
    Noor Alam
    1

    Sure ... Thanks

Please Sign in or register to post replies

Write your reply to:

Draft