'Umbraco.Web.PublishedContentModels.ProductDocuments' does not contain a definition for 'GetPropertyValue' error message
I am not sure why I get this error- "'Umbraco.Web.PublishedContentModels.ProductDocuments' does not contain a definition for 'GetPropertyValue'". I have used the same set up for other nested content on this page and it worked. If you have any insights on what might be wrong I would appreciate it.
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = "Master.cshtml";
var node = Model.Content;
var home = node.Site();
var productML = home.Descendant("markets");
var product = @CurrentPage.Parent().Descendants("product").First();
}
@foreach(var stuff in product.Children.Where("Visible")){
if (stuff.HasValue("relatedDocuments"))
{
foreach (var item in stuff.GetPropertyValue<IEnumerable<IPublishedContent>>("relatedDocuments"))
{
if (item.HasValue("documentFile") && item.HasValue("documentName"))
{
var file = item.GetPropertyValue<IPublishedContent>("documentFile");
<div class="boxspacenope">
<div class="outline3">
<div class="row">
<div class="col s6 m6 l6" align="left">
<div class="title3"><b>@item.GetPropertyValue("documentName")</b></div>
</div>
<div class="col s3 m3 l3" align="center">
</div>
<div class="col s3 m3 l3" align="center">
<ul class="links">
<li>
<a href="@file.Url" target="_blank"><div class="underline">Download</div></a>
</li>
</ul>
</div>
</div>
</div>
</div>
}
}
}
}
'Umbraco.Web.PublishedContentModels.ProductDocuments' does not contain a definition for 'GetPropertyValue' error message
I am not sure why I get this error- "'Umbraco.Web.PublishedContentModels.ProductDocuments' does not contain a definition for 'GetPropertyValue'". I have used the same set up for other nested content on this page and it worked. If you have any insights on what might be wrong I would appreciate it.
Hi Andrew,
I think this caused because you are mixing dynamic and strongly typed syntax for accessing content.
I wrote a article several years ago describing the difference between the two : https://24days.in/umbraco-cms/2015/strongly-typed-vs-dynamic-content-access/
So if you change this line :
To this :
Your code will probably work
Dave
is working on a reply...