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
Hello,
i try to use a doc type with a media picker property in a grid. My Template:
@inherits Umbraco.Web.Mvc.UmbracoViewPage @{ var typedMediaPickerSingle = Model.Content.GetPropertyValue<IPublishedContent>("image"); if (typedMediaPickerSingle != null) { <p>@typedMediaPickerSingle.Url</p> <img src="@typedMediaPickerSingle.Url" style="width:200px" alt="@typedMediaPickerSingle.GetPropertyValue("alt")" /> } }
This results in an exception, that 'Umbraco.Core.Models.IPublishedContent' does not contain no definition for 'Content'. How do i use it right? Thanks
Hi rkae
I think because you are inheriting UmbracoViewPage, you do not have a Content property representing an IPublishedContent instance on your model.
Have a look at this answer to explain the difference between UmbracoViewPage and UmbracoTemplatePage
https://our.umbraco.org/forum/developers/api-questions/52597-What-is-the-difference-between-UmbracoViewPage-and-UmbracoTemplatePage
So
var typedMediaPickerSingle = Model.GetPropertyValue<IPublishedContent>("image");
should work
You are correct, thank you!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
How to use media picker with doc type grid editor?
Hello,
i try to use a doc type with a media picker property in a grid. My Template:
This results in an exception, that 'Umbraco.Core.Models.IPublishedContent' does not contain no definition for 'Content'. How do i use it right? Thanks
Hi rkae
I think because you are inheriting UmbracoViewPage, you do not have a Content property representing an IPublishedContent instance on your model.
Have a look at this answer to explain the difference between UmbracoViewPage and UmbracoTemplatePage
https://our.umbraco.org/forum/developers/api-questions/52597-What-is-the-difference-between-UmbracoViewPage-and-UmbracoTemplatePage
So
should work
You are correct, thank you!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.