What are your thoughts on using an IDisposable to stripe an HTML table like so? It's a blatant abuse of IDisposable but this allows you to use the counter in a using(){} block which gives you a clear block in the markup.public class StripeCounter : IDisposable{    private string cssClass = stripe;    private int counter = 0;    public StripeCounter(){}    public StripeCounter(string cssClass)    {        this.cssClass = cssClass;    }    public MvcHtmlString Stripe()    {        return MvcHtmlString.Create(counter++ % 2 == 1 ? cssClass : string.Empty);    }    public void Dispose() { }}And then the markup@using (var counter = new StripeCounter()){    foreach (var item in Model)    {    <tr class=@counter.Stripe()>        <td>            ...        </td>       ...    </tr>    }}Regarding comments on using JavaScript to stripe the table:JavaScript is for behaviour and the striped rows of a table aren't behaviour; they are style, so while it is possible to do so on the client, it seem to me to be something that should be done on the server. For example, if someone has scripts disabled, they would still see the CSS striping, but not JavaScript striping.
Using IDisposable to stripe a table
c#;asp.net mvc 3