views:

18

answers:

1

Hello All,

I'm trying read an array that was post from a html form

<input name="test[]" id="1" type="checkbox" value="1" />
<input name="test[]" id="2" type="checkbox" value="2" />
<input name="test[]" id="3" type="checkbox" value="3" />
<input name="test[]" id="4" type="checkbox" value="4" />

In php I know you can just access the data very easily

foreach($_POST['test'] as $item)
{
    echo $item;
}

I've had a look around and haven't come across anything doing the same thing.

Any help would be greatly appreciated.

A: 

If you just get Request("test[]"), you should get back a comma-separated list of the values. I'm not sure how well that'd work if the values can have commas in them.

If you need the values as an array, you can check out Request.Form.GetValues("test[]"). It'll probably be null if the array is empty, though, so check for that before you use the array.

cHao