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
I'm trying to get a macro parameter "test" that is a multiple media picker and iterate the images to the page.
var mediaItems = Model.GetParameterValue<IEnumerable<IPublishedContent>>("test");
foreach (var item in mediaItems)
But I keep getting "System.NullReferenceException: Object reference not set to an instance of an object."
Am I looking at this the wrong way?
Old post but I like to have answers on them if people google and come across them...
The reason this did not work is because the item may not have any images selected and thus null.
You can either do a HasValue check or check that mediaItems is not null
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted