I am pretty new to MVC. In my form i have a disabled dropdown control whose value is not getting passed to the Model during submit as it is disabled. I tried using a hidden field like below
@Html.DropDownListFor(model => model.DepartmentID, new List<SelectListItem> { new SelectListItem { Text = "Item 1", Value = "1" }, new SelectListItem { Text = "Item 2", Value = "2", Selected = true } })
@Html.HiddenFor(model => model.DepartmentID)
Both of the above statement produce controls having the same id so i was not sure can i get the value of the dropdown in the hidden field.
I could use a different id while creating the hidden variable and assign the dropdown value it it using jquery.
I just want to know if i can achieve the same using the Hidden field having the same id as shown in the above code ??