I use the <% foreach ...%> loop to list a collection of elements on my website.
I want to add a different background color for the style of alternating lines in my list. I found a way to do this, but I am not happy with this, as it seems to be a hack.
Here is what I have done to solve it so far:
<table> <% int counter = 0; foreach (var item in Model) { counter++; if (counter % 2 == 0) { %> <tr class="colorfull"> <% } else { %> <tr> <% } %> ...
Is there any best practice that I skip that people use for this script in ASP.NET MVC?
jquery html stylesheet asp.net-mvc
Yeahstu
source share