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>

[Tutorial] SharePoint DataView WebPart Recursive Item DataSource

Create a DataVIew WebPart page by following guide :

1. Go to the SharePoint Site using SharePoint Designer.

2. Create a ASPX page

a. File > New > ASPX > OK

3. Inherit the MasterPage

a. Format > MasterPage > Attach Master Page … > custom Masterpage > /_catalogs/masterpage/xxx.master

4. Create on the arrow on the maincontent placeholder > Create Custom Content

clip_image001

5. Add WebPart Zone

a. Insert > SharepointControl > WebpartZone

6. Add Data View Webpart

a. Insert > SharepointControl > DataView

7. Drag “ListName” List to the DataView WebPart

8. Do Styling and Filtering Accordingly.

a. clip_image002

b. These lists contain folder, in order achieve to see the file only, the scope need to be defined as Recursive. To do that, just click on the current Data Source: on the position top right, and then select Recursive from Item and folder scope. Please apply this for both history and history details page in this case.

clip_image003

c. For the first field please custom it as <a href="<DetailsPage>.aspx?ItemId={@ID}"><xsl:value-of select="@Title" /></a> in your code behind.

d. Set the filter to only Created by equal to [Current User].

9. Now repeat step 1 to step 8 to create history detail page, note that the layout and column display is different.

10. Add a parameter to the DataView Webpart.

clip_image004

11. Set Filter ID field equal to [ItemId]

12. Save it and test on it.

14. Happy Coding !

Tuesday, October 12, 2010

[Tip] Sometime is hard to say i’m sorry SharePoint 2010

Have you ever face any problem when trying out with no bugs for your SP 2010 master page top navigation? impossible right? The followings are some knowledge sharing from me, hope it helps you…Sp2010 is damn “good”~!

image

It’s auto generated width:3px td in table for each single menu item.

It’s auto generate margin-left: 16px for each single menu item.

Solution :
Look for the AspMenu and add few attributes to the control so that it won’t render the extra pixel on our design…
<SharePoint:AspMenu
                    ID="TopNavigationMenuV4"
                    Runat="server"
                    EnableViewState="false"
                    DataSourceID="topSiteMap"
                    AccessKey="<%$Resources:wss,navigation_accesskey%>"  
                    UseSimpleRendering="false"      …

StaticSelectedStyle-ItemSpacing="0px"
StaticMenuItemStyle-ItemSpacing="0px"
StaticSubMenuIndent = "0px"

After that, you should get something like this screen

image