Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

MenuHelper.IsCurrent(obj) always returns true for root page
cfastner
#1 Posted : Tuesday, January 03, 2012 4:03:57 PM(UTC)
Rank: Newbie
Groups: Registered

Joined: 12/7/2011(UTC)
Posts: 9
Hi,
I'm playing around with the MenuHelper stuff.
I noticed, that if you use MenuHelper.Top() the method MenuHelper.IsCurrent(obj) always returns true
for the roor page.

Code:

@foreach (var topMenuItem in MenuHelper.Top())
     {
        var isCurrent = MenuHelper.IsCurrent(topMenuItem);

        <p>full name: @topMenuItem.FullName current: @isCurrent</p>

        if (topMenuItem.Navigation.Order == 2)
        {
           <li class ='@(MenuHelper.IsCurrent(topMenuItem) ? "currentMenuPage" : "")'>@Html.FrontHtml().PageLink(topMenuItem.LinkText, topMenuItem.FullName)</li>
         }
      }

isCurrent is always true for root page.

Maybe I'm missing a vital configuration for the root page?

thx,
cfastner
jifeng
#2 Posted : Wednesday, January 04, 2012 1:58:59 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,555
Location: Xiamen China
Here is the "Menu" view code in SampleSite:

Code:


<ul class="menu clearfix">
@foreach (var item in MenuHelper.Top())
{
    if (item.Navigation.Show)
    {
        <li class ='@(MenuHelper.IsCurrent(item) ? "current" : "")'>@Html.FrontHtml().PageLink(item.LinkText, item.FullName)</li>
    }
}</ul>



It works fine.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.253 seconds.