I have a page with forms on and I need to use the same page content elsewhere on the site.
I have managed to get the nested to work but then try and put the Form PDF URL in and it stops working. I am using the same process for images and they are working as expected.
@{
var FormPage = Umbraco.Content(2151);
var PDFImage = FormPage.FormPDFIcon;
var XLSImage = FormPage.FormXLSIcon;
var DownloadForms = FormPage.downloadableFormsNested;
var MouseOver = "";
foreach(var item in DownloadForms)
{
var FormLink = item.GetPropertyValue<IPublishedContent>("FormURL");
var FormTitle = item.GetPropertyValue("FormTitle");
var FormDate = item.GetPropertyValue<DateTime>("FormDate");
var FormImg = item.GetPropertyValue<IPublishedContent>("FormImg");
string ext = Path.GetExtension(@FormLink.Url);
switch (@ext)
{
case ".pdf":
MouseOver = @PDFImage.Url;
break;
case ".xls":
MouseOver = @XLSImage.Url;
break;
}
<div class="col-sm-3 border">
<center>
<a href="@item.FormLink.Url" target="_blank">
<p>@item.FormTitle</p>
<img src="@item.FormImg.Url">
<p>Form Date: @item.FormDate.ToString("MMM yyyy")</p></a>
</center>
</div>
}
}
Error I get is:
'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'GetPropertyValue'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'GetPropertyValue'
Source Error:
Line 107: {
Line 108:
Line 109: var FormLink = item.GetPropertyValue
And you have checked if that isn't null (double check in quick watch)
And this still doesn't have a URL.
Then the only time I have seen this issue is if the physical file has been deleted. So umbraco still things the data item exists but cant find a related file. I had the exact same issue before and it was driving me crazy.
If this sounds like the case then I would upload a new image from fresh then re select this new image in the backend. Save and Publish. Then test again in the frontend.
Ok so the same.
Check that the physical file exists.
My guess is you dont have the physical file on your machine.
This happens maybe if you have downloaded the live site locally and didn't pull down all the media. My guess is that specific media file has been lost somewhere.
I would test re-uploading the file through Umbraco backend and then re selecting the file on that item.
var DownloadForms = FormPage.downloadableFormsNested;
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'FormURL'
Source Error:
Line 104:
Line 105: foreach(var item in DownloadForms)
Line 106: {
Line 107:
Line 108:
I just had another thought since I saw your post on Facebook.
Regarding your comment...
All of the items work except FormURL it says it cannot be found. It is
a media picker. I have two of these in the nested item and the second
one works as expected.
If one is working and the other isn't. I am thinking is the second (the one not working) a new field you have added? If so are you using models builder or something like that and forgot to re-build the models?
Also what I would try if you dont have a lot of data and happy to fix the data up afterwards.
Try removing the field from the doc type so its full gone.
Then add a new field. I would even go as far as giving it a different name.
Then try and render this to the front-end like the working one.
Something strange is going on and this could potentially either fix the problem or help you figure it out at least.
Nested Content from another page
Hello,
I have a page with forms on and I need to use the same page content elsewhere on the site.
I have managed to get the nested to work but then try and put the Form PDF URL in and it stops working. I am using the same process for images and they are working as expected.
Error I get is:
'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'GetPropertyValue' Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'GetPropertyValue'
Source Error:
Line 107: { Line 108:
Line 109: var FormLink = item.GetPropertyValue
Changed the code slightly.
Now i get the error saying FormURL does not exist when it clearly does and not sure why this will not bring content through.
Here is the URL to the page with the code working without the FormURL in it. https://xpsbridge.sail-dev.com/lgps-members/forms-and-guides/forms/
I sit Umbraco 7 or 8?
If its Umbraoc 8 the correct code should be something like this.
I would also put an if statement around the link to check to see if that isn't null.
Regards
David
Hi David,
It's Umbraco 7.
It does not appear to be the GetPropertyValue.
It appears that the FormURL does not transfer into this nested item.
Hi Michael,
If the FormImg is an Image datatype.
And you have checked if that isn't null (double check in quick watch)
And this still doesn't have a URL.
Then the only time I have seen this issue is if the physical file has been deleted. So umbraco still things the data item exists but cant find a related file. I had the exact same issue before and it was driving me crazy.
If this sounds like the case then I would upload a new image from fresh then re select this new image in the backend. Save and Publish. Then test again in the frontend.
Regards
David
Hi David,
It's not an image its a file name.
It works on this page: https://xpsbridge.sail-dev.com/lgps-employers/forms/
But this page won't render the FormURL
https://xpsbridge.sail-dev.com/lgps-members/forms-and-guides/forms/
Ok so its this line of code?
@item.FormURL.Url
So what datatype is FormURL?
same as form img a media picker
Ok so the same. Check that the physical file exists. My guess is you dont have the physical file on your machine.
This happens maybe if you have downloaded the live site locally and didn't pull down all the media. My guess is that specific media file has been lost somewhere.
I would test re-uploading the file through Umbraco backend and then re selecting the file on that item.
Then test again. My guess is it will then work.
Still on the same machine sadly.
The Files work on the first page but not when I have linked across
I have never had problems with nested content displaying either images or documents.
So I highly doubt nested content is the blame.
I think it is how i am bringing the Nested content into the page that is causing more of the issue.
Hi David,
Here is how I am pulling the nested content from.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'FormURL'
Source Error:
Line 104: Line 105: foreach(var item in DownloadForms) Line 106: { Line 107:
Line 108:
Source File: D:\XPSBridge\Views\FormDisplayPage.cshtml Line: 106
Stack Trace:
[RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.DownloadForms' does not contain a definition for 'FormURL']
I just had another thought since I saw your post on Facebook.
Regarding your comment...
If one is working and the other isn't. I am thinking is the second (the one not working) a new field you have added? If so are you using models builder or something like that and forgot to re-build the models?
Also what I would try if you dont have a lot of data and happy to fix the data up afterwards.
Try removing the field from the doc type so its full gone. Then add a new field. I would even go as far as giving it a different name. Then try and render this to the front-end like the working one.
Something strange is going on and this could potentially either fix the problem or help you figure it out at least.
Regards
David
Hi David,
Thanks for replying.
The page that the content is edited on works fine.
https://xpsbridge.sail-dev.com/lgps-employers/forms/
I am then trying to replicate this page on another site so that the application Forms can be changed once.
This is where the content is not working correctly.
Actually I can see from your code you are not using models builder.
I would still try removing the field and adding it again.
Whey not add an extra field and leave that one as it is for the now to see if my ideas works first.
Umbraco confuses the hell out of me.
That has worked. I have created a new media picker called FormLink and it works as I expected it to.
What the .....
is working on a reply...