将自定义属性添加到ASP.NET MVC的SiteMap中 [英] Adding custom attributes to the SiteMap of ASP.NET MVC

查看:89
本文介绍了将自定义属性添加到ASP.NET MVC的SiteMap中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在带有以下架构的asp.net mvc中使用内置的asp.net站点地图

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

我具有以下属性,即资源键,标题&描述.我想向sitemapNode添加更多属性,请让我知道是否可以在sitemap文件中添加新属性,然后通过sitemap类进行读取.

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.

推荐答案

SiteMap模式支持自定义属性,可以通过SiteMapNode类的indexer属性对其进行访问.

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

例如,如果以下节点是使用自定义工具提示属性在Web.sitemap文件中定义的:

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" />

然后可以通过SiteMapNode索引器访问它,例如

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

string tooltip = siteMapNodeInstance["tooltip"];

有关自定义SiteMap的更多信息,请参见

More information on customising SiteMaps is available here

这篇关于将自定义属性添加到ASP.NET MVC的SiteMap中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆