ASP.NET MVC 2 - Retrieving the selected value from a dropdownlist and a listbox
I'm new to ASP.NET MVC and I'm using the example outlined in Steven Sanderson's book to create a multi-page, wizard like form for a web application.
(See http://books.google.com/books?id=lfPkn31fpNQC&pg=PA477#v=onepage&q&f=false for the exact example).
I have it working to the point where I can persist data across pages, but I have no idea how to do this for a DropDownList control or a开发者_开发知识库 ListBox control.
Can anyone show me how to do this?
Thanks.
Quite simply the dropdown list is an HTML select control, it's value will be in the form values posted to the action so if you set your form to post to an action then in the aciton you need:
public ActionResult RecieveForm(FormCollection values)
{
var dropdownSelectedvalue = values["nameofdropdown"];
...
work with result
...
return View()
}
精彩评论