It works, except when CurrentPage is the Homepage itself, then this line:
var cssClass = page.Id == CurrentPage.AncestorOrSelf(2).Id ? "active" : string.Empty;
throws a null reference exception:
"Cannot perform runtime binding on a null reference"
I already tried to solve it by changing the level:
var cssClass = page.Id == CurrentPage.AncestorOrSelf(1).Id ? "active" : string.Empty;
This solves the null reference error when CurrentPage is the Homepage but then the class="active" doesn't get added to the anchor link of the other nodes
Hi, I have mention below so my code related Menu. It's work for me but i want to display same navigation with other page means, which is not related with that all dynamic page.
I have created some manually page, and in that I want same menu which is displayed on my all other page.
so, can you guide me or suggest me how can i do ?
Top Menu Navigation with v6 Razor
Hi, anyone yet done a top menu navigation Partial View Macro File with v6 Razor?
thanks for your help,
Anthony
@Ali, again you come to the rescue.
Thanks a lot!
greetings,
Anthony
Hi Ali, your script works like a charm, I have one issue to solve however. All my pages are subnodes of Home
so currently the home node is not showing in the top menu navigation
so is there a way to adapt the script so the home node gets rendered as well?
Thanks for your help,
Anthony
Hi Anthony,
You might benefit from taking a look at NavIt It just installs a single flexible Partial View.
Jeavon
This should work
HI Ali,
It works, except when CurrentPage is the Homepage itself, then this line:
throws a null reference exception:
"Cannot perform runtime binding on a null reference"
I already tried to solve it by changing the level:
This solves the null reference error when CurrentPage is the Homepage but then the class="active" doesn't get added to the anchor link of the other nodes
this should fix it
it does, thanks a lot!
you are welcome Anthony!
Hi, I have mention below so my code related Menu. It's work for me but i want to display same navigation with other page means, which is not related with that all dynamic page. I have created some manually page, and in that I want same menu which is displayed on my all other page. so, can you guide me or suggest me how can i do ?
Thanks.
is working on a reply...