Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi all,
I want to create a carousel, firstly I create a nested content then I added it on my homepage but when I called, it's not working.
@{ string carouselId = "mainCarousel"; IEnumerable<IPublishedContent> carousel = Model.Value<IEnumerable<IPublishedContent>>(carouselId); }
I got error like this object reference not set to an instance of an object. I tried many things but I failed to reach on solve. Btw I'm using v8.1.12.
Hi Caglar
You have to use IPublishedElement instead of IPublishedContent like this:
@{ string carouselId = "mainCarousel"; IEnumerable<IPublishedElement> carousel = Model.Value<IEnumerable<IPublishedElement>>(carouselId); }
If you have single element nested content then like this:
IPublishedElement carousel = Model.Value<IPublishedElement>("mainCarousel");
All information needed for working with nested content you can find here - https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Nested-Content/
Thanks,
Alex
Hi Alex,
I got same error.
and what about IEnumerable<IPublishedElement>
IEnumerable<IPublishedElement>
It doesn't work . I really don't know why I'm getting this error.
My nested content;
Then I added this property on my home document type like as;
After, I filled with data in content menu and I clicked save&publish. After I called all this process on my partial view.
I fixed this problem with this code;
var page = Umbraco.Content(Guid.Parse("eea1803b-f093-42f6-8483-b27df3323c2d")); var carousel = page.Value<IEnumerable<IPublishedElement>>("mainCarousel");
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How can I get carousel on page?
Hi all,
I want to create a carousel, firstly I create a nested content then I added it on my homepage but when I called, it's not working.
I got error like this object reference not set to an instance of an object. I tried many things but I failed to reach on solve. Btw I'm using v8.1.12.
Hi Caglar
You have to use IPublishedElement instead of IPublishedContent like this:
If you have single element nested content then like this:
All information needed for working with nested content you can find here - https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Nested-Content/
Thanks,
Alex
Hi Alex,
I got same error.
and what about
IEnumerable<IPublishedElement>
It doesn't work . I really don't know why I'm getting this error.
My nested content;
Then I added this property on my home document type like as;
After, I filled with data in content menu and I clicked save&publish. After I called all this process on my partial view.
I fixed this problem with this code;
is working on a reply...