ASP.NET的Request对象

public static string GetRequestValue(HttpRequest Request, string strName)
{
string res = null;


//1. 当控件被禁用后,用 Request 获取对象时会报异常。

//2. 利用Request方法,可以读取其他页面提交过来的数据。
//提交的数据有两种形式:一种是通过Form表单提交过来,
//另一种是通过超级链接后面的参数提交过来,两种方式都可以利用Request对象读取。
//Request[对象名]获取的是 <Form > </Form>内的对象.


if (Request.Form[strName] != null)
{
try
{
res = Request.Form[strName];
}
catch { }
}
else
{
if (Request.QueryString[strName] != null)
{
try
{
res = Request.QueryString[strName];
}
catch { }
}
}

return res;
}

posted @ 2012-08-03 12:41  xust  阅读(142)  评论(0编辑  收藏  举报