views:

17

answers:

1

Greetings. I have some inputs dynamically added to form.

<input name="input_names[]" />

When form was posted, I can get these names like this:

var names = Request.Form["input_names[]"];

And I've got CSV string. It's not a problem and I can split it by comma. Problem happens when I write down text which includes comma. Then I cannot split this string correctly. Split method will divide single string into two or more and that's a problem. How can I avoid this problem?

+3  A: 

One way would be to call them:

<input type="text" name="inputNames" />
<input type="text" name="inputNames" />
...

And in your controller action:

[HttpPost]
public ActionResult Index(string[] inputNames)
{
    return View();
}

This way you don't have to worry about splitting. You controller action will already receive an array.

Darin Dimitrov
Thanks. It helped me
ck3g