Search This Blog

Friday, December 17, 2010

[Troubleshooting] SharePoint 2010 MasterPage Custom Top Navigation Issue

Do you face any problem to the top navigation link where you have added a custom link but end up it return you node and however you click and it gonna redirect you back to your root site… irony?

Please check if you are using this format? This is no problem when you are in SP2007, but SP2010 you will understand what i mean.

<SharePoint:AspMenu
                    ID="TopNavigationMenuV4"
                    Runat="server"
                    EnableViewState="false"
                    DataSourceID="topSiteMap"
                    AccessKey="<%$Resources:wss,navigation_accesskey%>"                 
                    Orientation="Horizontal"
                    StaticDisplayLevels="2"
                    StaticSelectedStyle-CssClass="xxxx"
                    MaximumDynamicDisplayLevels="1"
                    SkipLinkText=""
                    StaticEnableDefaultPopOutImage="False"              
                    CssClass="atq-topnav">    
                    <DynamicMenuStyle CssClass="xxx" />              
                    <DynamicMenuItemStyle CssClass="xxx" />                   
                    <DynamicHoverStyle CssClass="xxx"/>
                    <StaticItemTemplate>
                        <table  cellpadding="0" cellspacing="0">
                               <tr>                          
                                <td>

                                   <asp:HyperLink runat="Server" ID="LinkMenuItem" NavigateUrl='<%# Eval("DataPath")%>' Text='<%# Eval("Text")%>' /></td>
                                    </tr>
                        </table>
                    </StaticItemTemplate>
                </SharePoint:AspMenu>

VS.

Change the syntax as follow and you will able to solve the “unreachable” link issue.

<SharePoint:AspMenu
                            ID="TopNavigationMenuV4"
                            Runat="server"
                            EnableViewState="false"
                            DataSourceID="topSiteMap"
                            AccessKey="<%$Resources:wss,navigation_accesskey%>"
                            Orientation="Horizontal"
                            StaticDisplayLevels="2"
                            StaticSelectedStyle-CssClass="xxx"
                            MaximumDynamicDisplayLevels="1"
                            SkipLinkText=""
                            CssClass="s4-tn">
                            <StaticItemTemplate>

<table onclick="window.location=this.parentNode.href" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>

                                             <asp:Label runat="server" id="a1" text='<%# Eval("Text")%>'></asp:Label>     
                                        </td>
                                    </tr>
                                </table>
                            </StaticItemTemplate>
                        </SharePoint:AspMenu>

2 comments:

  1. I get this when I try to call <%# Eval("Text")%>

    Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

    ReplyDelete
  2. I get this when I try to call <%# Eval("Text")%>

    Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.

    ReplyDelete