title: Set Html.TextBoxFor not editable depending on a Model value
body: <p>I'm developing an ASP.NET MVC 5 app with Razor, C# and .NET Framework 4.7.</p>
  
  <p>I want to make it a textbox not editable if <code>Model.IsChinaProduct</code> is true.</p>
  
  <p>I have this piece of code in a View:</p>
  
  <pre><code>@Html.TextBoxFor(m =&gt; m.Configurations[index].PkgRatio, new { @class = "productClass", @onkeydown = "IsValidKey(event);" @if (Model.IsChinaProduct) disabled})
  </code></pre>
  
  <p>I want to add the <code>disabled</code> attribute if <code>Model.IsChinaProduct</code> is true, but that code shows me the following error:</p>
  
  <blockquote>
    <p>Error CS0746  Invalid anonymous type member declarator. Anonymous type
    members must be declared with a member assignment, simple name or
    member access.</p>
  </blockquote>
  
  <p>How can I add the <code>disabled</code> attribute if <code>Model.IsChinaProduct</code> is true?</p>
  
  <p><strong>UPDATE:</strong><br/>
  Maybe disabled is not the right attribute.</p>