I am writing a Razor Macro wherein I get the name of a Partial View dynamically.
I need to pass a list of Nodes to this Partial View and render it dynamically within the Razor Macro.
Is it possible?
Any directions on how can it be done?
Is your Razor Macro a Partial View Macro ? or Dynamic Node Razor Macro.
If you have a Partial View Macro then you should be able to call a further Partial view and pass a custom model of your list of nodes, eg
@{
IEnumerable<IPublishedContent> myNodeList = Umbraco.TypedContent(new string[] {"1123","1127","1125"});
// (or however you get your list of nodes)
//Render partial calls the partial view, and allows you to pass the custom model.
Html.RenderPartial("~/Views/Partials/TestPartialView.cshtml", myNodeList);
}
then your partial view should have a model based on the list of nodes eg.
Rendering a Partial View via Razor Macro
Hi
I am writing a Razor Macro wherein I get the name of a Partial View dynamically. I need to pass a list of Nodes to this Partial View and render it dynamically within the Razor Macro.
Is it possible? Any directions on how can it be done?
Thanks
Hi Jigar
Is your Razor Macro a Partial View Macro ? or Dynamic Node Razor Macro.
If you have a Partial View Macro then you should be able to call a further Partial view and pass a custom model of your list of nodes, eg
then your partial view should have a model based on the list of nodes eg.
then you should be able to loop through the nodes in your partial view with
Thanks Marc
That worked like a Charm!!
is working on a reply...