maartenba/MvcSiteMapProvider — Issue #22: Problems with using ImageUrl DynamicNodeProviderBase
Author: Ridermansb
Created: 2012-02-04 18:37:00+00:00
State: open

Apparently, the title takes the value of ImageUrl

In my DynamicNodeProviderBase class configure both the `Title` and the `ImageUrl`

**DynamicNodeProviderBase**

```c#
const string keyFormated = "Subsidiary_{0}";

// Create a node for each subsidiary
foreach (var subsidiary in listDB.ToList())
{
var node = new DynamicNode
{
Title = subsidiary.District,
Description = subsidiary.Title,
ImageUrl = Path.Combine(string.Format(Constants.RelativePathSubsidiary, subsidiary.ID.ToString().ToLower())),
Key = string.Format(keyFormated, subsidiary.District)
};
node.RouteValues.Add("id", subsidiary.ID);
node.Attributes.Add("LargeIconFileName", subsidiary.LargeIconFileName);
node.Attributes.Add("MediumIconFileName", subsidiary.MediumIconFileName);
node.Attributes.Add("SmallIconFileName", subsidiary.SmallIconFileName);
returnValue.Add(node);
}

// Return
return returnValue;
```

**View**

In my view, call the helper to generate the menu of my page.
This menu is customized by a DisplayTemplates

`@Html.MvcSiteMap().Menu("sitemap-menu", true, true, false)`

**DisplayTemplates**

Basically have a DisplayTemplates for the `MenuHelperModel` and one for the `SiteMapNodeModel`.
As `MenuHelperModel` is pretty simple (just call the helper `@DisplayFor` passing my custom template) will not put his code here.

The following code `SiteMapNodeModel`

```razor
@model SiteMapNodeModel
@{

object upper;
string title = Model.Title;
var imgUrl = Path.Combine(Model.ImageUrl, "Icons");
string iconFilename;
if (ViewData.TryGetValue("upper", out upper))
{
title = title.ToUpperInvariant();
}

if (Model.MetaAttributes.TryGetValue("SmallIconFileName", out iconFilename)
|| Model.MetaAttributes.TryGetValue("MediumIconFileName", out iconFilename)
|| Model.MetaAttributes.TryGetValue("LargeIconFileName", out iconFilename))
{
imgUrl = Path.Combine(imgUrl, iconFilename);
}
}

@if (Model.IsCurrentNode && Model.SourceMetadata["HtmlHelper"].ToString() != "MvcSiteMapProvider.Web.Html.MenuHelper")
{

@title

}
else if (Model.IsClickable && Model.ImageUrl != null)
{

@title

}
else
{

@title

}
```

But the values ​​are incorrect (or are exchanged).
See a picture of the debug:

**Debug**

![Debug mode](http://i.imgur.com/J5qwb.png)
See [full image here](http://i.imgur.com/J5qwb.png)

## Question

Why the value of the `ImageUrl` property is Title and why `TItle` is empty?