I need to change the background of a div based on some count property set in the code behind. I can get it to work as below. But i'm wondering if this is a good practice. If I need to change the count logic, I have to update code vs html. I suppose Jquery can't do this unless I have a hidden variable with count on the page. Is this better than writing an If loop logic within the html?
html
<div class="show <%=CSSClass %>"> value </div>
code behind
public string CSSClass
{
get
{
if (count > 1) return "bright";
else if (count == 0)
return "normal";
return "dim";
}
}
if else if. Did you really intend for"dim"to be mapped tocount == 1 || count < 0?count == 1? You current code returns"dim".