Reputation: 17
I have designed a razor-view that is bounded with model. This page containing multiple lists(drop-down). In some case depended child drop-down list is disabled. There is need to fetch it's value. Please help me for it.
Upvotes: 0
Views: 67
Reputation: 357
There is need to include a hidden field with the same name and value
@Html.DropDownListFor(x => x.StateId, Model.States, new { disabled = "disabled" })
@Html.HiddenFor(x => x.StateId)
Upvotes: 0
Reputation: 3248
Disabled controls will not post their values back to the server-side, see values of disabled inputs will not be submited? for extra info.
If you want to access the value you will have to store (copy) it somewhere else, such as an extra <input type="hidden"/>
Upvotes: 2