Domanda

Having a child action like this

public ActionResult Summaries(IPublishedContent currentPage)
{
    //...
}

I would need to pass from the masterpage the @CurrentPage to it, so I would need to use something like this

@Html.Action("Summaries", "Blog", CurrentPage )

But as @Html.Action cannot be dispatched dynamically I would need to cast CurrentPage and I'm lost there as then I wouldn't be able to use IPublishedContent but I would need a type to cast to.

Any help?

Thanks

È stato utile?

Soluzione

A child action like this

public ActionResult Summaries(umbraco.NodeFactory.Node currentNode)
{
    //...
    var value = node.GetProperty("myProperty");
}

Then you could just call you action like this

@Html.Action("Summaries", "Blog", umbraco.NodeFactory.Node.GetCurrent())

This would give you access to the state of the current node as well as traversing the parents and children of the nodes using things like node.GetChildNodes()

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top