c# - Asp.net 使用 Request.Form 从 c# 中的 html 表单获取发布的值并获取数组值
问题描述
<input type=hidden name='field[size][large]' value='40' />
<input type=hidden name='field[size][medium]' value='32' />
<input type=hidden name='field[size][small]' value='12' />
<input type=hidden name='field[color][green]' value='22' />
<input type=hidden name='field[color][blue]' value='30' />
我有一个像这样的表格我怎么可以使用Reuest.Form.GetValues("");
但不能确定的是如何获取上面表格中的值,例如输入名称是 field[size][large]
我尝试在这里使用一些示例,但是如果我对所有表单值进行循环,则无法获取值我可以看到诸如
foreach (string key in Request.Form)
{
sbError.Append("<br>Key : " + key + "=" + Request.Form[key]);
// Do something with (name, value).
// using this will output all form values but l want specifically for field[xxx][xxx] not all
}
.它将输出值。我的问题是我怎样才能field[xxx][xxx]
通过它们获得 or 循环中的所有值
更新 :
我正在使用 Angular 创建 html 输入值
field['am-created-by-angular']['created-by-angular']
所以基于字段获取值并遍历它并获取值。
l 不知道用户在客户端使用 angular 创建的值,但是会有字母数字 l 只需捕获值
解决方案
推荐阅读
- ios - ios - firebase 云混乱的混搭
- javascript - 有没有更好的方法来对对象数组进行排序以动态生成按值分隔的 HTML 元素?
- .net-core - 来自 .NET core 2.1 的 DB2 连接
- saml-2.0 - 尝试使用 OneLogin 实现多个 ACS 支持
- angular - 每次渲染组件时加载新数据或使用存储数据
- css - 是否可以按条件用css对div进行排序
- spring - Spring Security 应用程序登录不适用于 Jmeter
- javascript - 正则表达式:数组匹配
- javascript - 在 jquery 或 js 中滚动到子 div
- android - 可调用和未来延迟android主线程