Welcome Guest Search | Active Topics | Sign In | Register

Using SiteMap Navigation with Menu Options
Augie
Posted: Wednesday, June 24, 2009 10:33:38 AM
Rank: Member
Groups: Member

Joined: 6/19/2009
Posts: 12
Hello, I am trying to use the sitemap datasource to create the menu. However, if I set the databindings for the menu, the text is correct but the url is not. If I do not set the bindings it works fine but I wanted to be able to set the image URL for the top level menuitem - can I do this?

By bindings are:
Code: HTML/ASPX
<eo:Menu runat="server" ID="MainNav" 
    DataSourceID="MenuSiteMap" TopLevelItemAlign="Right" Width="100%">
    <TopGroup Style-CssText="cursor:hand;font-family:arial;" DefaultItemLookID="_Default">
        <Bindings>
            <eo:DataBinding Property="Value" DataField="@title" />
            <eo:DataBinding Property="Image-Url" DataField="@image-URL"></eo:DataBinding>
            <eo:DataBinding Property="NavigateUrl" DataField="@url" />
        </Bindings>
    </TopGroup>


Using:

Code: HTML/ASPX
<asp:SiteMapDataSource runat="server" ID="MenuSiteMap" ShowStartingNode="false" />


SiteMap:

Code: HTML/ASPX
<siteMapNode url="~/Performance.aspx" title="MenuItem 1"  description="MenuItem 1" image-URL="~/images/NavHeadings.gif" >
            <siteMapNode url="~/Performance.aspx?i=0" title="MenuItem 2"  description="" />
            <siteMapNode url="~/Performance.aspx?i=1" title="MenuItem 3"  description="" />
            <siteMapNode url="~/Performance.aspx?i=2" title="MenuItem 4"  description="" />
            <siteMapNode url="~/Performance.aspx?i=3" title="MenuItem 5"  description="" />
            <siteMapNode url="~/Performance.aspx?i=4" title="MenuItem 6"  description="" />
        </siteMapNode>


I am sure the issue is something simple, but I have not been able to glean enough information from the forum posts.

Thank you in advance...


eo_support
Posted: Wednesday, June 24, 2009 11:19:17 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You won't be able to do it this way. When you bind the menu to a SiteMapDataSource, the "data item" is a SiteMapNode object. It is not an XmlNode. So syntax like "@title" does not work.

There are two ways to resolve this issue:

1. Instead of setting the menu's DataSourceID, set the menu's XmlFile directly to the name of your site map file. This way the menu will use the XML based logic to populate. That way it should correctly interpret "@title", "@image_URL" correctly;

2. Still use DataSourceID, but handle the menu's ItemDataBound event and use the following code to explicitly read "image-URL" from the site map file and set the menu item's Image.Url based on it:

Code: C#
protected void Menu1_ItemDataBound(
    object sender, EO.Web.NavigationItemEventArgs e)
{
    SiteMapNode node = (SiteMapNode)Menu1.DataItem;
    string imageUrl = node["image-URL"];
    e.MenuItem.Image.Url = imageUrl;
}


Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.