I want to do something like this:
View
<td class="[email protected]">
@Model.Description
</td>
CSS
<style type="text/css">
.status_True
{
background-color: Red;
}
.status_False
{
background-color: Green;
}
</style>
@Model.IsActive is return True or False. Of course this code is not working.
Html output of class is : class="[email protected]"
My expected output is : class="status_True"
Is this possible to do something like this logic? If is possible, How can I do? Or another way to change css class? There may be different ways.
Thanks.
Razor syntax takes some getting used to. Use parenthesis to get the actual property value:
<td class="status_@(Model.IsActive)">
Here's a quick reference from Phil Haack
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With