检索ASP.NET中的所有已发布值 [英] Retrieve all posted values in ASP.NET

查看:128
本文介绍了检索ASP.NET中的所有已发布值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个ASP.NET应用程序,允许用户将表单元素添加到表单中的页面。当页面发布时(通过提交按钮)我需要遍历表单中的所有发布值并获取值。

I am creating an ASP.NET application that allows the user to add form elements to a page within a form. When the page is posted (via the submit button) I need to loop through ALL the posted values in the form and get the values.

我无法检查具体的因为我不知道将会有多少或者它们将被称为什么。

I can't check for specific values as I don't know how many there will be or what they will be called.

有人能指出我正确的方向获得所有发布的值,所以我可以循环通过它们?

Could someone point me in the right direction of getting ALL posted values so I can loop through them?

ps我正在查看Request.Form但看不到任何明显可用的东西。

p.s I was looking in Request.Form but couldn't see anything obvious to use.

谢谢。

推荐答案

Request.Form 属性返回 NameValueCollection 你可以迭代:

The Request.Form property returns a NameValueCollection you can iterate over:

foreach (string name in Request.Form.AllKeys) {
    string value = Request.Form[name];
    // Do something with (name, value).
}

这篇关于检索ASP.NET中的所有已发布值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆