Monday 6 October 2014

Render special character '&' as html In SharePoint 2010 Menu

Today I was working with one of the designer in my company on Flyout Menu for one of or new SharePoint 2010 site. Since some of the page title had special characters like '&' (&), the SharePoint Menu was rendering with special character  (&)


The solution is to add EncodeTitle="false" in the AspMenu control as below.

<SharePoint:AspMenu ID="CurrentNav" runat="server" 
   datasourceID="SiteMapDS" 
   orientation="Vertical" 
   StaticDisplayLevels="2" 
   MaximumDynamicDisplayLevels="0" 
   StaticSubMenuIndent="1" 
   ItemWrap="true" 
   UseSimpleRendering="true"
   AccessKey="3" 
   SkipLinkText=""
   EncodeTitle="false"></SharePoint:AspMenu>
    <PublishingNavigation:PortalSiteMapDataSource ID="SiteMapDS" Runat="server" 
   SiteMapProvider="CurrentNavSiteMapProvider" 
   EnableViewState="true" 
   StartFromCurrentNode="true" 
   StartingNodeOffset="0" 
   ShowStartingNode="false" 
   TrimNonCurrentTypes="Heading"/>