如何获取POST过来的所有值?

fengjing888 2009-02-09 04:32:21
<form method="post" action="C:\Documents and Settings\Administrator.SYBOTT003\Desktop\at.html">
<table>
<tbody><tr><td>w3exec: </td><td><input name="w3exec" value="actinput" type="text"></td></tr>
<tr><td>customerNo: </td><td><input name="customerNo" value="17174" maxlength="32" type="text"></td></tr>
<tr><td>userID: </td><td><input name="userID" value="sybottad" maxlength="128" type="text"></td></tr>
<tr><td valign="top">style: </td><td><input name="NoteDetail" value="12/01/08:this is a test_line2_line3;12/31/08:this is another test_line2;01/31/09:this is last entry_lin2_line3" maxlength="1152" type="text"> <br>

</td></tr>
<tr><td>  </td><td><input value="Test actinput ..." type="submit"></td></tr>
</tbody></table>
</form>

代码如上所示:我在取值时Request.Form["NoteDetail"].ToString();可以取到NoteDetail的值,能否一次性取到上面四个参数的值?
...全文
1345 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cngothic 2009-02-09
  • 打赏
  • 举报
回复
晓月大哥说的遍历Request.Form 可读性强。个人用它不习惯对于数组索引与传递参数位置如有错乱以后工作我就迷糊了。。。
Jinglecat 2009-02-09
  • 打赏
  • 举报
回复
遍历 Request.Form 集合
cngothic 2009-02-09
  • 打赏
  • 举报
回复
一个参数一个值。
一个参数要写一个request.querything来获取。
fengjing888 2009-02-09
  • 打赏
  • 举报
回复
有没有办法一次取得
w3exec=123&customerNo=234&userID=521¬eDetail=12/01/08:this is a test_line2_line3;12/31/08:this is another test_line2;01/31/09:this is last entry_lin2_line3
这样格式的值?
liujiayu10 2009-02-09
  • 打赏
  • 举报
回复
<form method="post" action="C:\Documents and Settings\Administrator.SYBOTT003\Desktop\at.html">
action的值一定是虚拟地址,我上面说了

另外
接受参数:Request.QueryString["customerNo"]


建议先看看ASP方面的资料
sugercgq 2009-02-09
  • 打赏
  • 举报
回复
错了,不好意思
liujiayu10 2009-02-09
  • 打赏
  • 举报
回复
C:\Documents and Settings\Administrator.SYBOTT003\Desktop\at.html

这是绝对地址,这样是不行的,必须是虚拟路径如:xx.aspx或admin/xx.aspx或http://www.test.com/admin/xx.aspx
sugercgq 2009-02-09
  • 打赏
  • 举报
回复
/// <summary>
/// 得到 Request 的全部
/// </summary>
/// <param name="_str"></param>
/// <returns></returns>
public static string all(string _str)
{
if (HttpContext.Current.Request[_str] != null)
return HttpContext.Current.Request[_str].ToString();
return string.Empty;
}

flyrain521 2009-02-09
  • 打赏
  • 举报
回复
用request.params
request.params其实是一个集合,它依次包括request.querystring、

request.form、request.cookies和request.servervariables。

如果要在两个页面传递数据的话,只能用request.querystring、request.form、

request.cookies

Request.Params 是在 QueryString、Form、Server Variable 以及 Cookies

找数据,

他首先在 QueryString 集合查找数据,如果在 QueryString 找到数据,就返

回数据,如果没有找到就去 Form 集合中查找数据,找到就返回,否则在往

下一下个集合查找数据。
Request.Params["id"]、Request.Form["id"]、Request.QueryString["id"]的用法以及区别?
Request.Params是所有post和get传过来的值的集合,
Request.Form是取post传值, Request.QueryString是get传过来的值

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧