'Display a table with different sections having different colors
how can I change the background in an html table dynamically to have different sections be different colors?
I'm using MVC Razor HTML jquery C#
I can set it manually
<tr style="background-color: #D7816C" >
but using a variable doesn't work
<tr style=@bc >
preferably being able to set it with some logic in the foreach loop
<div> @{ bc = "background-color: #8ED76C"; } </div>
Solution 1:[1]
Actually this worked, i just needed to put the variable in quotes
<tr style="@bc" ></tr>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kostas Minaidis |
