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
I have two properties in my DocType - A textstring(focusImage1) and an Upload(focusImage1 )- both for img. links.
In my template I'll then try to display either one of them, or a static img.
@if (item.focusImage1 != ""){ <img src="@item.focusImage1" alt="@item.Name" />}else if(item.focusImage2 != null){ <img src="@item.focusImage2" alt="@item.Name" />}else{ <img src="/images/skin2012/transparent_1x1.gif" alt="" />}
However I keep getting the same error: Operator '!=' cannot be applied to operands of type 'umbraco.MacroEngines.DynamicNull' and 'string'
NM - I figuered it out myself, but feel free to use the solution - I simply added this to my if-statement:
item.focusImage1.ToString().Trim() != ""item.focusImage2.ToString().Trim() != ""
Works like a charm now... :-)
Hi Robin,
You can also use String.IsNullOrWhiteSpace and/or String.IsNullOrEmpty. Like this:
@if(!String.IsNullOrEmpty(item.focusImage1)){ Do something}
Is use it often.
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
Declare if dataType Upload TextString and is empty (not in use)
I have two properties in my DocType - A textstring(focusImage1) and an Upload(focusImage1 )- both for img. links.
In my template I'll then try to display either one of them, or a static img.
However I keep getting the same error: Operator '!=' cannot be applied to operands of type 'umbraco.MacroEngines.DynamicNull' and 'string'
NM - I figuered it out myself, but feel free to use the solution - I simply added this to my if-statement:
Works like a charm now... :-)
Hi Robin,
You can also use String.IsNullOrWhiteSpace and/or String.IsNullOrEmpty. Like this:
Is use it often.
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.