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
Just struggling with syntax on an MVC template. Seems like something straight forward but I just cant' get it to work.
Essentially I am trying to show a section if a true/false value is true..something like this, but it's obviously not correct
@if ("@Umbraco.Field("optInAsset") == True") { <p>TRUE..so show this stuff</p> } else { <p>false yo</p> }
Hi Brian,
How about this?
@if(CurrentPage.optInAsset == "True"){ <p>TRUE..so show this stuff</p>}else{ <p>false yo</p>}
Hope this helps,
/Dennis
Hi Dennis, thanks for your help...that didn't seem to do it either...gave me an error:
"Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Operator '==' cannot be applied to operands of type 'bool' and 'string'"
This seems to be doing the trick though:
@if ((Umbraco.Field("optInAsset").ToString() == "True")) { <p>Show this stuff</p> } else { <p> show this other stuff</p> }
not sure if it's the best way but it's doing the trick for now..thanks
If optInAsset is a data type using the "True/False" property editor then this can be simply
@if(CurrentPage.optInAsset){ <p>TRUE..so show this stuff</p> }else{ <p>false yo</p> }
Thanks Jeavon, that helped me out too!
I was stuck with the classic case of over complicating!
Some documentation on querying can be found here
Hi Jeavon, Thanks!..Nice..your answer works great..
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Syntax on Boolean if statement in partial view template
Just struggling with syntax on an MVC template. Seems like something straight forward but I just cant' get it to work.
Essentially I am trying to show a section if a true/false value is true..something like this, but it's obviously not correct
Hi Brian,
How about this?
Hope this helps,
/Dennis
Hi Dennis, thanks for your help...that didn't seem to do it either...gave me an error:
"Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Operator '==' cannot be applied to operands of type 'bool' and 'string'"
This seems to be doing the trick though:
not sure if it's the best way but it's doing the trick for now..thanks
If optInAsset is a data type using the "True/False" property editor then this can be simply
Thanks Jeavon, that helped me out too!
I was stuck with the classic case of over complicating!
Some documentation on querying can be found here
Hi Jeavon, Thanks!..Nice..your answer works great..
is working on a reply...