Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding custom attributes to the SiteMap of ASP.NET MVC

I am using built in asp.net sitemap in asp.net mvc with the following schema

http://schemas.microsoft.com/AspNet/SiteMap-File-1.0

I have the following attributes, resourcekey, title & description. I would like to add few more attributes to the sitemapNode, kindly let me know if it is possible to add new attribute in sitemap file and then read it via the sitemap class.

like image 973
Saravanan Avatar asked Aug 10 '12 07:08

Saravanan


1 Answers

The SiteMap schema supports custom attributes and they can be accessed via the indexer property of the SiteMapNode class.

For example if the following node was defined in the Web.sitemap file with custom tooltip attribute:

<siteMapNode url="~/Default.aspx" title="Home" tooltip="My Home Page" />

It can then be accessed via the SiteMapNode indexer e.g.

string tooltip = siteMapNodeInstance["tooltip"];

More information on customising SiteMaps is available here

like image 163
Rob Willis Avatar answered Oct 22 '22 16:10

Rob Willis