Reputation: 39675
I'm using MvcSiteMapProvider
to create breadcrumbs in my ASP.NET MVC application. I have some dynamic resources which I want to create some child nodes for. Some of these nodes, I want to appear in breadcrumbs but not be clickable.
For a static resource, you can specify clickable="false"
in the XML sitemap document and these nodes will appear, but will not be hyperlinks. I can't find an equivalent property to set on the DynamicNode
returned by my dynamic node provider class.
Is it possible to add a dynamic, "unclickable" node?
Upvotes: 0
Views: 612
Reputation: 56909
In v4 there is now a Clickable property on the dynamic node, and setting an attribute to clickable will now cause an error, because the properties are no longer backed by the Attributes dictionary.
var node = new DynamicNode();
node.Clickable = false;
Upvotes: 1
Reputation: 39675
DynamicNode
doesn't have n Clickable
property, because it does not inherit from the MvcSiteMapNode
class.
Reflecting on MvcSiteMapNode
shows that the implementation of Clickable
is backed by the Attributes
property:
public bool Clickable
{
get
{
return ((this["clickable"] == null) || bool.Parse(this["clickable"]));
}
set
{
this["clickable"] = value.ToString();
}
}
The DynamicNode
class exposes its own Attributes
property, which is copied to the MvcSiteMapNode
instance when the dynamic nodes are parsed. The property can therefore be set using this code:
var node = new DynamicNode();
node.Attributes["clickable"] = "false";
Upvotes: 1