title: How to set html attributes such as class using MVC Razor?
body: <p>How to set html attributes using when Razor?</p>
  
  <p>In the below code, I'd like to set the class attribute of  element if "Succeeded" property of the current model is true.</p>
  
  <pre><code>&lt;tbody&gt;
                  @foreach (CharlieTestRunViewModel charlieTestRunViewModel in Model)
      {
                      &lt;tr class="@if(!@charlieTestRunViewModel.Succeeded){'trFailedTestRun'}"&gt;
                          &lt;td&gt;
                              @charlieTestRunViewModel.Succeeded
                          &lt;/td&gt;
                                      &lt;/tr&gt;
      }
              &lt;/tbody&gt;
  </code></pre>
  
  <p>But it doesn't work.</p>
  
  <p>How to achieve this?</p>
  
  <p>Thanks</p>