Html.DropDownList - Disabled/Readonly

前端 未结 14 883
无人共我
无人共我 2020-12-01 08:51

What option do I need to set to make a drop down box readonly when using MVCs Html.DropDownList?

I\'ve tried things like....

Html.DropDownList(\"Type         


        
14条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 09:22

    Regarding the catch 22:

    If we use @disabled, the field is not sent to the action (Mamoud) And if we use @readonly, the drop down bug still lets you change the value

    Workaround: use @disabled, and add the field hidden after the drop down:

    @Html.HiddenFor(model => model.xxxxxxxx)
    

    Then it is truly disabled, and sent to the to the action too.

提交回复
热议问题