asp.net - SiteMap change SiteMapProvider? -
i've got custom menu navigation built web.sitemap file, first line of like:
sitemapnodecollection toplevelnodes = sitemap.rootnode.childnodes;
this works - gets top level nodes web.sitemap file, , allows me through each sitemapnode , stuff.
however, want able create multiple web.sitemap files, , programmatically determine web.sitemap file use, can't seem find out how this. i'm assuming either create 1 custom sitemapprovider can perform logic determine web.sitemap file load, or have multiple providers, each 1 sitemapfile property set specific *.sitemap file, , switch providers programmatically before access sitemap.rootnode.
i think it's easier have 1 custom provider, , override part looks actual physical sitemap file location, i'm unclear how
i've googled lot, answers seem regarding standard sitemappath controls , on, , how set sitemapdatasource, don't think relevant approach.
first need specify of sitemap files in web.config such:
<sitemap defaultprovider="fndsitemap" enabled="true"> <providers> <add name="fndsitemap" type="system.web.xmlsitemapprovider" sitemapfile="fnd.sitemap" securitytrimmingenabled="true"/> <add name="stasitemap" type="system.web.xmlsitemapprovider" sitemapfile="sta.sitemap" securitytrimmingenabled="true"/> <add name="tasitemap" type="system.web.xmlsitemapprovider" sitemapfile="ta.sitemap" securitytrimmingenabled="true"/> </providers> </sitemap>
then in code-behind can dynamically assign sitemapdatasource (which bound menu) 1 of providers specified in web.config:
.aspx
<asp:menu id="menulevel1" runat="server" orientation="horizontal" datasourceid="sitemaplevel1" maximumdynamicdisplaylevels="0" includestyleblock="false"> </asp:menu> <asp:sitemapdatasource id="sitemaplevel1" runat="server" />
.cs
sitemaplevel1.sitemapprovider = "tasitemap";
Comments
Post a Comment