Hi there,
By adding a custom handler to the SiteMapResolve event, I can update sitemap url's on the fly, by some logic that I define.
This is ok for SiteMapPath controls, that appear to use this SiteMapResolve functionality... however I want to achieve a similar result for an asp.net Menu control that uses a SiteMapDataSource. Altering nodes with the SiteMapResolve handler doesn't have any effect.
Could anyone point me in the right direction? cheers :D
edit:sourcecode I've removed everything unnecessary and am left with the following - I must be misunderstanding something to do with the structure of the menuItemCollecton but it's always empty.
web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="default.aspx" title="Homepage" description="Home">
<siteMapNode url="secondpage.aspx" title="Page 2" />
</siteMapNode>
</siteMap>
default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu runat=server ID=menu DataSourceid=dsSiteMap />
<asp:SiteMapDataSource ID="dsSiteMap" runat="server" />
<asp:Label runat=server id=lbMenuCount />
</div>
</form>
</body>
</html>
default.aspx.vb
Partial Class _Default Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lbMenuCount.text = menu.Items.Count
End Sub
End Class