Ok, so I'm building bread crumbs and depending on the value of the breadcrumb an image will be the seperator. So "HOME" will have one image and "SEARCH" will have another.
I know I can do this programatically (at least I ASSUME) but is there an easier way to do this? Can I link an image to a node based on the value of the node? Can I do it with PathSeparatorTemplate?
Thank you.
I see you have already accepted an answer, but I thought some code would help, so here is some:
<asp:SiteMapPath ID="SiteMapPath1" Runat="server" OnItemDataBound="Item_Bound">
<PathSeparatorTemplate>
<asp:Image ID="SepImage" runat="server" ImageUrl="/images"/>
</PathSeparatorTemplate>
</asp:SiteMapPath>
private string lastItemKey = "";
public void Item_Bound(Object sender, SiteMapNodeItemEventArgs e)
{
if (e.Item.ItemType == SiteMapNodeItemType.PathSeparator)
{
string imageUrl = ((Image) e.Item.Controls[1]).ImageUrl;
imageUrl += lastItemKey + ".png";
((Image) e.Item.Controls[1]).ImageUrl = imageUrl;
}
else
{
lastItemKey = e.Item.SiteMapNode.Key;
}
}
Then I have an /images
directory containing an image for each of the Key
's of the SiteMapNode
s. In other terms: this code will result in the image being displayed, after each of the path nodes, to depend on the key of the node before it.
Hope this helps someone.