title: Disabled DropDownList razor mvc
body: <p>In my razor view, I use a drop down list. I want to have this control disabled (not selectable). </p>
  
  <p>My code is:</p>
  
  <pre><code>&lt;div class="field-list"&gt;@Html.DropDownListFor(model =&gt; model.LinguaCodiceMadre, Model.LinguaMadreList, new{ @disabled = "disabled" })&lt;/div&gt;
  </code></pre>
  
  <p>But it doesn't work, my control is always enabled. Html page code is:</p>
  
  <pre><code>&lt;select name="LinguaCodiceMadre" id="LinguaCodiceMadre" data-val-length-max="10" data-val-length="The field LinguaCodiceMadre must be a string with a maximum length of 10." data-val="true"&gt;
      &lt;option&gt;&lt;/option&gt;
      &lt;option value="sq"&gt;Albanian&lt;/option&gt;
      &lt;option value="de"&gt;German&lt;/option&gt;
      &lt;option value="en"&gt;English&lt;/option&gt;
      &lt;option value="fr"&gt;French&lt;/option&gt;
      &lt;option value="it"&gt;Italian&lt;/option&gt;
      &lt;option value="pt"&gt;Portuguese&lt;/option&gt;
      &lt;option value="ru"&gt;Russian&lt;/option&gt;
      &lt;option value="es"&gt;Spanish&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>without the "disabled" attribute.</p>
  
  <p>My real goal is to enable/disable dropdown conditionally, something like this:</p>
  
  <pre><code>&lt;div class="field-list"&gt;@Html.DropDownListFor(model =&gt; model.LinguaCodiceMadre, Model.LinguaMadreList, new{@disabled=Model.IsDisabled ? "disabled" : "false"})&lt;/div&gt;
  </code></pre>
  
  <p>but it doesn't work. </p>
  
  <p>I tried both with </p>
  
  <pre><code>new{@disabled=Model.IsDisabled ? "disabled" : "false"}
  </code></pre>
  
  <p>and </p>
  
  <pre><code>new{disabled=Model.IsDisabled ? "disabled" : "false"}
  </code></pre>
  
  <p>but nothing, disabled attribute is not rendering on html page.</p>
  
  <p>Anyone has an idea?</p>