将自定义属性添加到ASP.NET MVC的SiteMap中

编程入门 行业动态 更新时间:2024-10-19 12:47:40
本文介绍了将自定义属性添加到ASP.NET MVC的SiteMap中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

schemas.microsoft/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中

本文发布于:2023-11-15 02:52:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1590496.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   属性   ASP   SiteMap   MVC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!