Share via


ASP.Net 2.0 Navigation and SharePoint v3

Jon Hello everyone, Jon here again with a quick tip. If you have ever wanted to use the new navigation features of ASP.Net 2.0 in your site, you might have noticed that it doesn't work in the way described by the tutorial when you are on a SharePoint v3 based site. The key is that you need to specify the SiteMapProvider that you want, because SharePoint sets the default sitemap provider to be SPSiteMapProvider. If you want the standard non-SharePoint behavior, you should specify SiteMapProvider="AspNetXmlSiteMapProvider" on your asp:SiteMapDataSource.

<asp:TreeView runat="server" id="MyTreeView" DataSourceID="MySiteMap"/>
<asp:SiteMapDataSource runat="server" ID="MySiteMap" SiteMapProvider="AspNetXmlSiteMapProvider"/>

Enjoy!
Jon

Comments

  • Anonymous
    October 15, 2007
    PingBack from http://www.artofbam.com/wordpress/?p=8900

  • Anonymous
    October 16, 2007
    Thanks Jon, I've been working on this lately. The missing piece for me is how do you tell the datasource which xml file to use? Does the name have to match the ID?

  • Anonymous
    October 19, 2007
    What would be really helpful, and has been asked for repeatedly since SharePoint 2001 is either native Designer functionality or an add-on that allows one to pick from a wide range of nav styles, adjust the style (vertical, horizontal, have many levels to cascade, etc.) then tie it to the prover, all in a drag and drop environement. This should be a Designer tool function not handcrafted code.

  • Anonymous
    November 01, 2007
    Dion - I think you have to modify your web.config to get the provider to point to a different file. You will want to find the providers section and add a new provider, or modify the existing AspNetXmlSiteMapProvider. Here is some sample markup that should be pretty close to what you need.    <siteMap>      <providers>        <add name="MyFileXmlSiteMapProvider"              type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"              siteMapFile="/_layouts/mysuperfile.xml"          />      </providers>    </siteMap> http://msdn2.microsoft.com/en-us/library/1e333zt4(VS.80).aspx

  • Anonymous
    December 01, 2007
    We just went through a very painful exercise to apply styles to the left nav.  Mostly because the nav is positioned using embedded tables - not CSS.  Needed to parse and re-render the HTML to get the background changed across all the rows in the multiple tables that make up the currently selected item.  Time consuming development effort and runtime performce issue too. I've heard this from numerous other who try to mess with customizing the navigation.

  • Anonymous
    December 03, 2007
    Jeff: ouch! I feel your pain - that is definitely an area where we can do better. If you haven't found it already, definitely check out http://heathersolomon.com/blog/archive/2007/01/26/6153.aspx - its a fairly clean masterpage that you can use as a starting point for customization of the look and feel. From what I have seen its an ideal way to get a DIV based layout for your page. Also, http://www.heathersolomon.com/blog/articles/sp2007.aspx has some resources about branding that might help you with the styling of specific controls on the page like the left nav. If those resources don't help, then please file a bug at http://connect.microsoft.com or let us know more about the issue so we can evaluate the situation. Thanks

  • Anonymous
    February 06, 2008
    Regarding the limitations customizing the QuickLaunch: I noticed that you have a little more flexibility with design if you simply use the base Menu control and tie it to the SPSiteMapProvider.  But unless I am missing something, the key limitation is the inability to customize the raw HTML that's rendered for a particular element, like in LevelSubMenuStyles.  Ideally I'd like to wrap a level in <DIV> tags so that DHTML can hide/show or collapse/expand the next level.  But we are only given a small set of named properties to work with.

  • Anonymous
    February 29, 2008
    The code bloated default navigation needs a sleek replacement indeed. I am currently trying to implement http://www.codeproject.com/KB/sharepoint/MossVerticalNav.aspx in my Sharepoint installation. It seems promising as it allows me to style it using CSS. Anyway, since I may have the attention of someone from the Sharepoint team, please read the blog entries at http://friendlybit.com/css/sharepoint-2007-from-an-interface-developers-view/ and http://friendlybit.com/html/default-html-in-sharepoint-2007/ as it provides good feedback on how the community wants Sharepoint to evolve. thanks