I have an ASP.NET MVC app that uses Razor in the views. In my view, I have the following:
<table style="width:100%;">
...
</table>
I want to say, if (items.Count == 0), then the background color of the table should be orange. However, if (items.Count > 0), I want the background color of the table to be gray. How do I do this with Razor?
Thank you!
Just to give one more option, you can set color at page begining.
@{
var color = items.Any() ? "#CCC" : "#FF0";
}
And at your table tag
<table style="color:@color"></table>
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