ASP.NET:自定义动态填充站点地图(SiteMapProvider) [英] ASP.NET: Custom dynamically populated site map (SiteMapProvider)

查看:112
本文介绍了ASP.NET:自定义动态填充站点地图(SiteMapProvider)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着写我的第一个自己的 SiteMapProvider 子类。这意味着使用很多不同的数据库查找的被动态填充,就像所有的,我在网​​上找到的例子。

I'm trying to write my first very own SiteMapProvider subclass. It is meant to be populated dynamically using a bunch of different database lookups, much like all of the examples I've found on the web.

不过,也有事情是相当不清楚我一大堆。这里是我的两个第一问题:

However, there are a whole bunch of things that are quite unclear to me. Here are my two first questions:


  • 为什么 StaticSiteMapProvider 适用于几乎每个人的项目,而不是 SiteMapProvider 的?由于类包含名为静,我得到了IM pression我所想要的,它并不像......嗯,动感十足。

  • 有人能为我提供了超简约 SiteMapProvider 子类只使用静态数据填充其映射,即,没有数据库访问等?

  • Why is StaticSiteMapProvider used in virtually everyone's project instead of SiteMapProvider? Since the class contains the name "static", I'm getting the impression that it's not as...well, dynamic as I want it.
  • Can someone provide me with a super-minimalistic SiteMapProvider subclass which populates the map using only static data, i.e. no database access, etc.?

推荐答案

SiteMapProvider 可tottaly动态。例如,它可以使动态查找只是为节点。在 StaticSiteMapProvider 相反,你应该知道的整体结构。因此,这由你来决定选择什么。

SiteMapProvider can be tottaly dynamic. For example it can make dynamic lookup just for nodes. In contrast with StaticSiteMapProvider you should know whole structure. So this for you to decide what to choose.

您可以看一下静态的地图提供商的 XmlSiteMapProvider ,这是很好的例子。

You can look at the XmlSiteMapProvider, this is good example of "static" map provider.

public class CoolMapProvider : StaticSiteMapProvider
{
    public override SiteMapNode BuildSiteMap()
    {
        var root = new SiteMapNode(this, "test", "~/test.aspx");
        base.AddNode(root, null);

        base.AddNode(new SiteMapNode(this, "test-child", "~/test_child.aspx"), root);

        return root;
    }
}

我没有检查这一点,但应该工作。

I did not checked this, but should work.

这篇关于ASP.NET:自定义动态填充站点地图(SiteMapProvider)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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