title: Conditionally change CSS class in Razor view
body: <p>I need to change the CSS class of the <code>&lt;div&gt;</code> tag with the 'forumChild' class. It has to change every 3 loops of the foreach loop.</p>
  
  <p>Is there a way to do this from within the control?</p>
  
  <pre><code>&lt;div class="Forum"&gt;
      &lt;p&gt;The Forum&lt;/p&gt;
  
              @foreach (var item in Model)
              {               
                  &lt;div class="ForumChild"&gt;
  
                      &lt;img src="@item.Blog.Image.img_path" alt="Not Found" /&gt;
  
                      &lt;br /&gt;
                              @foreach (var comment in item.Blog.comment)
                              {
  
                                  var db = new ACapture.Models.ACaptureDB();
  
                                  var Name = from p in db.Profile.AsEnumerable()
                                             where (p.AccountID == comment.AccountID)
                                             select p;                            
                              &lt;section&gt;
                                      &lt;div&gt;
                                          &lt;a href="@Url.Action("Index", "Home")"&gt;@foreach (var y in Name)
                                                                                { @(y.FirstName + " " + y.LastName + ":");
                                                                                }&lt;/a&gt;
                                      &lt;/div&gt;
                                      &lt;div&gt;
                                          @comment.Commentation 
                                      &lt;/div&gt;
                              &lt;/section&gt;
                              }
                  &lt;/div&gt;                
              }
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks in advance</p>