Compiler Error Message:CS1061: 'Umbraco.Cms.Web.Model.Content' does not contain a definition for 'HasProperty' and no extension method 'HasProperty' accepting a first argument of type 'Umbraco.Cms.Web.Model.Content' could be found (are you missing a using directive or an assembly reference?) Source Error:
Line 32: @{
Line 33: if (Model.HasProperty("footerPhoto")) {
Fuji -
Compiler Error Message:CS1061: 'Umbraco.Cms.Web.Model.Content' does not contain a definition for 'footerPhoto' and no extension method 'footerPhoto' accepting a first argument of type 'Umbraco.Cms.Web.Model.Content' could be found (are you missing a using directive or an assembly reference?) Source Error:
Line 32: @{
Line 33: if(String.IsNullOrEmpty(@Model.footerPhoto.ToString()) == false){
Test if image exists, and display if it does
Hello,
This might sound easy but I can't get it to work.
In my document type I have defined a footerImage (of type Uploader) which is optional.
In my template I want to try to display the image only if it exists.
I know I need some sort of if statement around the below line and I have tried many and all fail. What is the simple solution to this problem.
<img src="@Umbraco.GetMediaUrl(Model.Id, "footerPhoto")" alt="@CurrentPage.Name" />
I am using Umbraco 5.
Regards,
Tom
See if this one (or something along these lines) suits you:
... works in v4.7.2
Hi Tom.
You could do something like this to check if image has been uploaded
//fuji
Thanks for the two replies.
Neither works.
Halldór Hrafn -
Compiler Error Message: CS1061: 'Umbraco.Cms.Web.Model.Content' does not contain a definition for 'HasProperty' and no extension method 'HasProperty' accepting a first argument of type 'Umbraco.Cms.Web.Model.Content' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 32: @{ Line 33: if (Model.HasProperty("footerPhoto")) {
Fuji -
Compiler Error Message: CS1061: 'Umbraco.Cms.Web.Model.Content' does not contain a definition for 'footerPhoto' and no extension method 'footerPhoto' accepting a first argument of type 'Umbraco.Cms.Web.Model.Content' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 32: @{ Line 33: if(String.IsNullOrEmpty(@Model.footerPhoto.ToString()) == false){
It appears that you are using Umbraco 5 and both of those solutions are for Umbraco 4.7.
Yes, Umbraco 5
is working on a reply...