title: Html.TextBox conditional attribute with ASP.NET MVC Preview 5
body: <p>I have a strongly-typed MVC View Control which is responsible for the UI where users can create and edit Client items.  I'd like them to be able to define the <code>ClientId</code> on creation, but not edit, and this to be reflected in the UI.</p>
  
  <p>To this end, I have the following line:</p>
  
  <pre><code>&lt;%= Html.TextBox("Client.ClientId", ViewData.Model.ClientId, new 
   { @readonly = 
     (ViewData.Model.ClientId != null &amp;&amp; ViewData.Model.ClientId.Length &gt; 0 
        ? "readonly" : "false") 
   } )
  %&gt;
  </code></pre>
  
  <p>It seems that no matter what value I give the readonly attribute (even "false" and ""), Firefox and IE7 make the input read-only, which is annoyingly counter-intuitive.  Is there a nice, ternary-operator-based way to drop the attribute completely if it is not required?</p>