ASP.NET: Custom dynamically populated site map (SiteMapProvider)

后端 未结 1 900
别那么骄傲
别那么骄傲 2021-01-14 06:05

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

1条回答
  •  礼貌的吻别
    2021-01-14 06:46

    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.

    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.

    0 讨论(0)
提交回复
热议问题