[英]vb.net handle a post with an array
I'm trying read an array that was post from a html form 我正在尝试读取从html表单发布的数组
<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 在PHP中,我知道您可以非常轻松地访问数据
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. 任何帮助将不胜感激。
If you just get Request("test[]")
, you should get back a comma-separated list of the values. 如果仅获得Request("test[]")
,则应返回以逗号分隔的值列表。 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[]")
. 如果需要将值作为数组,则可以签出Request.Form.GetValues("test[]")
。 It'll probably be null if no boxes were checked, though, so check for that before you use the array. 但是,如果未选中任何框,则可能为null,因此请在使用数组之前进行检查。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.