Reputation: 33850
I have a simple View like so:
@using (Html.BeginForm())
{
<select id="myList" style="width: 50%">
@for(int i = 0; i < 10; i++)
{
<option value="@i">Item @i</option>
}
</select>
<input type="submit" />
}
And the corresponding actions
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(int? myList)
{
Debugger.Break();
return View();
}
When I click the Submit button, though, the request body, as seen in inspectors such as Firebug and Fiddler, and also as reported by the myList
parameter of the Index
action, is empty.
Why is that so?
Upvotes: 0
Views: 227
Reputation: 68687
Give the select element a name
attribute.
<select id="myList" name="myList" style="width: 50%">
Upvotes: 1