I am generating a dynamic nav on my page using a traverse helper, but I need to find a way to prevent it from creating an empty <ul> tag for the navigation when there are no children of the current page to display. Here is what I have.
You're always going to hit your helper class (and therefore output your Unordered List tags as page will never be null as there always will be a self.
I do something similar using the CurrentPage object... you can use the Any() method - you could just wrap an if around what you already have if that works at the moment.
Help with Navigation
Hello,
I am generating a dynamic nav on my page using a traverse helper, but I need to find a way to prevent it from creating an empty <ul> tag for the navigation when there are no children of the current page to display. Here is what I have.
You're always going to hit your helper class (and therefore output your Unordered List tags as page will never be null as there always will be a self.
I do something similar using the CurrentPage object... you can use the Any() method - you could just wrap an if around what you already have if that works at the moment.
@if (CurrentPage.Children().Any()){
<ul>
.... <li> CODE HERE </li>
}
Thanks Steve, but I am using ver. 4.11 with webforms and I don't believe that I have that object class.
is working on a reply...