I have a document type "Person" and i want to create a partial view, where i can give a dynamic amount of persons, which should then be displayed.
I tried it like this:
My Template:
@{
//i get the persons from the multinode treepicker
var persons = Umbraco.Content(Umbraco.Field("persons").ToString().Split(','));
}
<p>these persons are involved:</p>
@Html.Partial("showPersons", (DyanmicPublishedContentList)persons)
And this is my Partial View:
@model DynamicPublishedContentList
<ul>
@foreach(var person in Model)
{
<li>@Model.GetPropertyValue("personPrename") @Model.GetPropertyValue("personSurname")</li>
}
</ul>
I get this error:
Compiler Error Message: CS0246: The type or namespace name
'DynamicPublishedContentList' could not be found (are you missing a
using directive or an assembly reference?)
This doesn't work in any Way... I'm looking for a good solution for my case...
I already did it with calling the partial for every person like this:
Could you not pass in an IEnumerable of IPublishedContent?
So your partial view will be something like this....
@model IEnumerable<IPublishContent>
foreach(var person in Model)
{
<p>@Model.GetPropertyValue("personPrename") @Model.GetPropertyValue("personSurname")</p>
}
@{
//I get the persons from the multinode treepicker
var persons = Umbraco.Content(Umbraco.Field("persons").ToString().Split(','));
}
<p>these persons are involved:</p>
@Html.Partial("showPersons", (IEnumerable<IPublishedContent>)persons)
Partial View
@model IEnumerable<IPublishedContent>
<ul>
@foreach(var person in Model)
{
<li>@person.GetPropertyValue("personPrename")</p>
}
</ul>
Call a Partial View with a Parameter
Hi everyone
I have a document type "Person" and i want to create a partial view, where i can give a dynamic amount of persons, which should then be displayed.
I tried it like this:
My Template:
And this is my Partial View:
I get this error:
This doesn't work in any Way... I'm looking for a good solution for my case...
I already did it with calling the partial for every person like this:
Template:
Partial View:
But i need to be able to display multiple persons with one partial view for design reasons...
Thanks for your help.
Greets, Silvan
Could you not pass in an IEnumerable of IPublishedContent?
So your partial view will be something like this....
Great! This solved my problem, thanks!
The solution now looks like this
Template
Partial View
Greets, Silvan
is working on a reply...