I have a dropdown as follows:
@Html.DropDownList("studentList", myModel.GetMyList())
I have a variable that stores the selected value in javeascript.
userID = $("#studentList> option:selected").attr("value")
However, I need to send the seleted value in c# to my controller. How can I achive that?
How do I read the selected value from the dropdown in c# or how can I “translate” the javascript value in c# varaiable?
It’s “Simple”, Create a HiddenField, and store the selected values in that, before post your data to server.
to get the selected values try something like that:
On then server-side, just have to split the string to get the values