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 a true/false property and need to add a class to a table cell based on this being true.
The property is productOne and if it's been set to True I need
<td class ="tick"></td>
Otherwise
<td></td>
However no matter what I've tried I just can't figure out how to do this. Any ideas? Thanks.
Hi Martin
What version of Umbraco are you trying to achieve the above on? And do you mind sharing the razor code you have been trying to get to work?
/Jan
Hi, I'm using v 5.02
I tried various things e.g.
<td class="@(Umbraco.Field("productOne") == "True" ? "tick" : "")"></td>
Compiler Error Message: CS0019: Operator '==' cannot be applied to operands of type 'System.Web.IHtmlString' and 'string'
<td class="@(Umbraco.Field("productOne").ToString == "True" ? "tick" : "")"></td>
Compiler Error Message: CS0019: Operator '==' cannot be applied to operands of type 'method group' and 'string'
@if("productOne == True")
{
<text><td class="class"></td></text>
}
else
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'bool'
Cheers
Got it working. My second try should obviously have been -
<td class ="@(Umbraco.Field("productOne").ToString()=="True" ? "tick" : "")"></td>
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
CSS class based on property
I have a true/false property and need to add a class to a table cell based on this being true.
The property is productOne and if it's been set to True I need
Otherwise
However no matter what I've tried I just can't figure out how to do this. Any ideas? Thanks.
Hi Martin
What version of Umbraco are you trying to achieve the above on? And do you mind sharing the razor code you have been trying to get to work?
/Jan
Hi, I'm using v 5.02
I tried various things e.g.
Compiler Error Message: CS0019: Operator '==' cannot be applied to operands of type 'System.Web.IHtmlString' and 'string'
Compiler Error Message: CS0019: Operator '==' cannot be applied to operands of type 'method group' and 'string'
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'bool'
Cheers
Got it working. My second try should obviously have been -
<td class ="@(Umbraco.Field("productOne").ToString()=="True" ? "tick" : "")"></td>
is working on a reply...