save variable from <select> in View into the ViewModel ASP-NET MVC

So I have a ViewModel with this attribute

public string number { get; set; }

And in my View I have the next drop down list:

<select>
    <option value="1">one</option>
    <option value="2">two</option>
    <option value="3">three</option>
    <option value="4">four</option>
</select>

How do I save the value that gets selected on the drop down list into the number attribute from my ViewModel?
Usually I would use @Html.DropDownListFor(m => m.number, listObject) but the dropdownlist that I’m trying to create has to be dynamically created with JQuery, therefore I can’t use the HtmlHelper.


Source: html

Leave a Reply