This what I did to add a separator to ASP.Net menu. I used Web.sitemap to bind the data to menu control. This how Web.sitemap looks like.
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode>
<sitemapnode url="~/Pages/DatingHome.aspx" title="Home" description="" separatorImageUrl="../../Images/but_blueSlice.jpg">
<sitemapnode url="~/Pages/Inbox.aspx" title="Inbox" description="" separatorImageUrl="../../Images/but_blueSlice.jpg">
</sitemapnode>
</sitemapnode>
This separatorImageUrl will tell you the image path of the separator. This event handler will do the rest of it.
protected void Menu2_MenuItemDataBound(object sender, System.Web.UI.WebControls.MenuEventArgs e)
{
SiteMapNode smNode = (SiteMapNode)e.Item.DataItem;
if (smNode["seperatorImageUrl"] != null)
e.Item.SeparatorImageUrl = smNode["seperatorImageUrl"];
}
This is it. Hope you all have something to get from it. :)
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode>
<sitemapnode url="~/Pages/DatingHome.aspx" title="Home" description="" separatorImageUrl="../../Images/but_blueSlice.jpg">
<sitemapnode url="~/Pages/Inbox.aspx" title="Inbox" description="" separatorImageUrl="../../Images/but_blueSlice.jpg">
</sitemapnode>
</sitemapnode>
This separatorImageUrl will tell you the image path of the separator. This event handler will do the rest of it.
protected void Menu2_MenuItemDataBound(object sender, System.Web.UI.WebControls.MenuEventArgs e)
{
SiteMapNode smNode = (SiteMapNode)e.Item.DataItem;
if (smNode["seperatorImageUrl"] != null)
e.Item.SeparatorImageUrl = smNode["seperatorImageUrl"];
}
This is it. Hope you all have something to get from it. :)
Comments
You can declare something like siteMapNode title="<hr class='separator'>" description="separator"/> in your sitemap.
In your css file:
.separator
{
cursor:default;
}
And in your code behind, while binding the sitemap to the menu:
protected void MenuItem_DataBound(object sender, MenuEventArgs e)
{
if (e.Item.ToolTip == "separator")
e.Item.Selectable = false;
}
Hope this helps someone,
Regards,
Julien