M_ary  
本人热爱编程...更期待和谐的团队.. 有意者,请发送邮件与我.. wangkang198802@126.com

1、用 Request.QueryString[""];

例如:

  Request.QueryString["id"];//如果有一个id,就用Querying[];来获取,返回字符串;

  //如果有多个,这样取也不会出错,只是取出来各个值之间是用英文逗号(,)隔开的,

2、用 Request.QueryString.GetValue(" ");--要想分别获取各个id;可以使用该方式,得到数组,然后用序号来获取。

例如:

  string[] ids = Request.QueryString.GetValues("id");   Response.Write(ids.Length + "<br>"); //长度   Response.Write(Request.QueryString.GetValues["id"][num]); //获取指定值

3、只有 GetKey 没有 GetKeys

一个 Key 可以对应多个 Value,但一个 Value 只能对应一个 Key,所以 GetValues 要用复数,而 GetKey 要用单数。

考察这个 QueryString:id=1&id=2&p=3

Request.QueryString.GetKey(1) 的值是多少?id 还是 p?应该是 p,也就是说前面两个 Key 都是 id,实际上它就是一个 Key,那么第二个 Key(用 1 表示)就是 p 了。

Request.Form 与 Request.QueryString 类似。

posted on 2011-07-27 16:58  M_ary  阅读(1116)  评论(5)    收藏  举报