Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor - Change Color of text based on condition

$
0
0

I have this five ratings:

    if (model.CIIattainedrequired2021 > model.d4)    {        model.CIIrating2021 = "E";    }    if (model.CIIattainedrequired2021 < model.d4)    {        model.CIIrating2021 = "D";    }    if (model.CIIattainedrequired2021 < model.d3)    {        model.CIIrating2021 = "C";    }    if (model.CIIattainedrequired2021 < model.d2)    {        model.CIIrating2021 = "B";    }    if (model.CIIattainedrequired2021 < model.d1)    {        model.CIIrating2021 = "A";    }

I display them in tables:

<td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2019</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2020</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2021</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2022</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2023</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2024</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2025</p></td><td class="text-center px-2 py-1 mx-0 text-xs"><p>@model.CIIrating2026</p>

And depending on the answer i would like to show the text in different colors as follow:

A-GREENB-LIGHTGREENC-YELLOWD-ORANGEE-RED


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>