Im using the MVC Contrib project to generate my menu system for an MVC site.
How does one generate attributes in your <a href tag based on your SiteMap. Ive managed to achieve this by specifying the attributesToIgnore="target" in my provider definition in my web.config and adding the attribute to my mvcSiteMapNode element in my sitemap file.
<mvcSiteMapNode title="Hello World"
controller="Home"
action="Index"
changeFrequency="Always"
updatePriority="Normal"
target="_blank">
</mvcSiteMapNode>
I then iterate through my SiteMap file pick of the attribute using
siteMapNode["target"]
and render it myself as <a href="#" target="_blank" > </a>. Is there a better way to do this?
Have you tried creating a SiteMapNodeModel display template? That allows you to construct your anchor tag however you wish. I created one to specifically add a class to the anchor if the node was in the current path so that I could apply specific CSS.
Here is the razor partial view I use:
The file, named “SiteMapNodeModel.cshtml” (razor) goes in Shared/DisplayTemplates. When asp.net Mvc rendors a SiteMapNodelModel it will automatically use this template.