My Web application requires that each page have a QueryString with a specific Name/Value pair, whose value is generated dynamically at logon to the site. In the Page_Load event handler for each page I retrieve the value from the QueryString. At this point
I need to append the same QueryString to each of the SiteMapNodes in the SiteMap that are parents of the current node. I have attempted to loop through each of the RootNode’s children and append the QueryString but the SiteMapNodes are read only. Any ideas
on how to accomplish this?
I have attempted to loop through each of the RootNode’s children and append the QueryString but the SiteMapNodes are read only
I’m assuming you would typically modify NavigateUrl property of MenuItem(if you are using Menu contol)/TreeNode(if you are using TreeView control). Are you using SiteMapDataSource to display some sort of navigation menu in the page header?
I’m using the SiteMap to display "breadcumbs" at the top of each page. Not a Tree and not a Menu but the simple horizontal site map. I’m using the simple approach as shown in
http://msdn.microsoft.com/en-us/library/ms178425(v=vs.100).aspx, "How to: Programmatically Modify Site-Map Nodes in Memory"
Here is what I do, there is no need to loop through the Nodes:
AddHandler SiteMap.SiteMapResolve, AddressOf Me.ConstructSiteMap Private Function ConstructSiteMap(ByVal sender As [Object], ByVal e As SiteMapResolveEventArgs) As SiteMapNode ' This sets the SiteMapPath, so we can add QueryStrings... otherwise the SiteMapPath will not render Dim currentNode As SiteMapNode If SiteMap.CurrentNode Is Nothing Then currentNode = e.Provider.FindSiteMapNode("~/default.aspx") Else currentNode = SiteMap.CurrentNode.Clone(True) End If Return currentNode End Function