I have an MVC 3 project, that I am starting, using c# and Razor. I have a page, that has about 20 input fields that will be used. I create my ViewModel to pass the data to the View to create the page. I am confused as to, how I get the values of the fields, when the user submits the form.
Does my Controller have to have a parameter for every input field on my page? Is there any way to have the Controller get all the data on the page and then I can parse through it? The parameter list would be huge.
You can just use the same model that you passed to your view as the parameter in your subsequent action.
An example:
The model object in the second method will automatically be populated from the data included in the HTTP request (the technical name is “Model Binding”).