views:

29

answers:

1

Hello,

I have a view with a form..this form has a textbox and a checkbox in it.

i also have a submit button in the form which points to an action in a controller.

my question is..how can i pass the values in the textboxes and the checked state of the checkboxes to the controller action?

the textboxes and checkboxes are not tied to a model.

thanks

A: 

You have two options.

The best option would be to create a ViewModel. This model doesn't need to have any logic or anything behind it, just a public get/set for the properties. This means you can also use the MVC validation, helpers and binding on the values and makes it easier to work with.

The alternative is for your action to accept a FormCollection, this is basically a dictionary with the form values, the keys being the name attribute on your form elements.

Chao