我刚看到一个帖子,楼主可能初学。
奇怪,Request.Form为什么不能获取html传递来的数据?
http://community.csdn.net/Expert/topic/5716/5716068.xml?temp=.2434198
我回复的是
//只有form method="get"时才可用Request.QueryString["one"]方法
//string one = Request.QueryString["one"];
//string two = Request.QueryString["two"];
//只有form method="post"时才可用Request.Form方法,否则出错, action="Response_2.aspx"
//string one = Request.Form["one"];
//string two = Request.Form["two"];
//只有它,才不被post,get方式限制呢。Request.Params好象是2.0新支持的
string one = Request.Params["one"];
string two = Request.Params["two"];
//它也不被post,get方式限制呢。
//string one = Request["one"];
//string two = Request["two"];
如果不是服务控件,可能用以下方法取值
<input id="Text1" type="text" name="first"/>
Requst.Form["first"] 中 ClientElementName 指的是 html 的 name 属性
希望对更多的初学者有帮助。
对了,对于学的值还要进行,判断
1.0/1.1中
if(Request["one"]==null||Request["one"]==String.Empty)
{
//空的或是NULL
}
2.0中
if(String.IsNullOrEmpty(Request["one"]) == true)
{
//空的或是NULL
}