Last post May 14, 2006 04:59 AM by SlackmasterK
May 12, 2006 05:01 PM|TheSneak|LINK
I want to create my SiteMap entirely at runtime. This means my Web.sitemap has only one siteMapNode with a title of "Home." I use the
SiteMapResolveEventHandler to dynamically create a
SiteMapNode and set its parent to the root node. The problem is that when i process the next page I want to set the newly created node's parent to the node I created on the previous page but I can't find a collection
that contains that node. The root node that I get from the provider or the SiteMap never has any children because, i guess, it's based exclusively on Web.sitemap and setting the parent of my dynamic SiteMapNode does not appear to make it be included in that
collection. What collection do I need to use to look at my dynamically created nodes? Do I need to manually add it to a collection, and if so, how? Or do I need to maintain my own collection?
May 12, 2006 05:30 PM|billrob458|LINK
I'm not sure how bold you want to get in solving this, but you would easily? implement your own SiteMapProvider that could return a dynamically generated site map.
Here are some articles from MSDN that will help you get started.
A custom SiteMapProvider should give you all the dynamicness as well as persistence you need to accomplish your goal. You could also google "Custom SiteMapProvider" and that should give you some more leads.
May 13, 2006 01:42 AM|SlackmasterK|LINK
Just yesterday I tackled that very problem. I implemented a rather unorthodox (but still fast) method that simply builds the XML from scratch. Lazy me, I just used strings and System.IO.File.WriteAllText , but it works. Substitute your own conditions and
values (obviously), but my implementation also solved your issue:
Something like that. Obviously, this includes implementing a connection to it in web.config and configuring the SiteMapDataSource, but the important thing is it works. Note it uses a string you can dissect and analyze all you want.
May 14, 2006 04:53 AM|ReyN|LINK
if you already have a database of what you intend to view in your sitemap, you can actually skip writing the XML and bind the database directly to whatever navigation control you need to, on demand.
this example shows how to populate a TreeView from a database
May 14, 2006 04:59 AM|SlackmasterK|LINK
Spiffy. Will have to give it a look.
For now, I'm busy reveling in figuring out how to bypass GoDaddy's decision to prevent .mdb file uploads (Bypassed by creating an aspx file to do it for me!).