Disable dropdown list in MVC3

34 views Asked by At

I have filled up dropdown as: Controller:

var db = new TransFormezEntities()           
ViewBag.fldCountry_ID = new SelectList(db.tblCountries, "fldCountry_ID", 
                                    "fldCountryName", stateDetails.fldCountry_ID)

View

Country
<div class="display-field" id = "fldCountry_ID">
      @Html.DropDownList("fldCountry_ID", "[Select]")
</div>

I want to make it readonly or disable how can i please ?

1

There are 1 answers

0
Cris On

try following code snippets

For disabled

  Html.DropDownList("fldCountry_ID", ViewBag.fldCountry_ID ,
                                       new { @disabled = "disabled" })

For readonly

Html.DropDownList("fldCountry_ID", ViewBag.fldCountry_ID , 
                                  new { @readonly = "true" })