Thursday, 22 August 2013

Changing Color of a Local Variable (as HTML Output) based on Condition

Changing Color of a Local Variable (as HTML Output) based on Condition

I have a problem with one of the code of my application. I have a Item
Category Block in my application. Which goes like this
NewsITEM1 (2) | NewsITEM2 (0) | NewsITEM3 (14)
The above represents ITEM Description and (Count_of_The_Item) under bracket.
Now The user need some customization , they need (Count_of_The_Item) to be
Red whenever the count is other that "0" . For example in NewsItem1(2) and
NewsItem3(14) -- (2) and (14) should be in RED where as in NewsITEM2 (0)
-- (0) should come as General Black.
string newsCount = sectionInfo.NewsItemsCount.ToString();
if (bookmarkForCategory.Length > 0) bookmarkForCategory.Append(" | ");
bookmarkForCategory.Append("<a href='#" + title + "'>" + title + "</a>" +
" (" + newsCount + ")");
In the above code you could see the newsCount variable is populating. With
Normal CSS properties it is getting printed as Black. Now we want to make
it RED whenever the newsCount variable value is other that "0" .
Requesting your help to resolve this.

No comments:

Post a Comment