title: How to conditionally add CSS class to Html.TextBoxFor
body: <p>Can anyone help me how to add CSS class conditionally to Html.TextBoxFor in my razor view.</p>
  
  <p>I am trying the following:</p>
  
  <pre><code>@Html.TextBoxFor(x =&gt; model.DateTimeStamp, new { @readonly = "readonly"}, ViewBag.IsNew ? (object)new {@class="test" }:null)
  </code></pre>