سؤال

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

هل كانت مفيدة؟

المحلول

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()

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top