1

I am trying to display a dropdown list for an enum set with a css class and disabled attribute.

This in on a .Net Framework 4.6.2 project. I have tried setting the htmlAttribute parameter, like the documentation (and all blog posts) suggests, but the resulting html does not include the html attributes.

Code from the View:

@Html.EnumDropDownListFor(model => model.FundingDataSource, htmlAttributes: new { @class = "disabled", @disabled = "disabled" })

Expected

<select id="FundingDataSource" name="FundingDataSource" class="disabled" disabled="disabled"> 
    <option value=""></option>
    <option value="1">Option 1</option>
    <option selected="selected" value="2">Option 2</option>
</select>

Actual Html:

<select id="FundingDataSource" name="FundingDataSource"> 
    <option value=""></option>
    <option value="1">Option 1</option>
    <option selected="selected" value="2">Option 2</option>
</select>

Any thoughts or suggestions on what is going wrong?

schulze101
  • 11
  • 3

1 Answers1

0

Similar to this post, try removing the word htmlAttributes instead:

@Html.EnumDropDownListFor(model => model.FundingDataSource, new { @class = "disabled", @disabled = "disabled" })
cwalvoort
  • 1,851
  • 1
  • 18
  • 19