Problem with checking if property exists with Razor (uBlogsy)
I'm simply trying to check if a page has an associated image, eg:
@{ if (d.HasProperty("mainImage") { <p>Do one thing...</p> } else { <p>Do another...</p> } }
This one obviosuly doesn't work, but I've tried:
if (String.IsNullOrEmpty(d.GetProperty("mainImage").ToString())==false){
... and a bunch of others, but noting works! Every page *has* the property, but some may not have an image uploaded (I'm using Upload data type, not Media library). In XSLT I'd simply check for an empty string being returned to indicate that no image had been uploaded for the current page...
Problem with checking if property exists with Razor (uBlogsy)
I'm simply trying to check if a page has an associated image, eg:
@{if (d.HasProperty("mainImage") {
<p>Do one thing...</p>
} else {
<p>Do another...</p>
}
}
This one obviosuly doesn't work, but I've tried:
if (String.IsNullOrEmpty(d.GetProperty("mainImage").ToString())==false){... and a bunch of others, but noting works! Every page *has* the property, but some may not have an image uploaded (I'm using Upload data type, not Media library). In XSLT I'd simply check for an empty string being returned to indicate that no image had been uploaded for the current page...
Any ideas?
OK, seems it's this:
Robin
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.