日期:2014-05-18  浏览次数:20404 次

怎么从html到asp.net传递参数?
我是这样做的,但服务器始终取不到

html:
<form   action= "queryzhan.aspx "   name= "zhanzhan "   method= "post ">
<div>
出发地: <input   type= "text "   size= "10 "   maxlength= "10 "     class= "url "   id= "chufa "   /> &nbsp;&nbsp;   目的地: <input   type= "text "   size= "10 "   maxlength= "10 "     class= "url "   id= "zhongdian "   /> <input   type= "submit "   value= "查询 "   id= "sub "     />
</div>
</form>

asp.net里面通过以下两种方法都取不到:
System.Web.HttpContext.Current.Request.Form[ "zhongdian "]
System.Web.HttpContext.Current.Request.QueryString[ "zhongdian "]

------解决方案--------------------
方法1
html method= "get "

<form action= "queryzhan.aspx " name= "zhanzhan " method= "get " ID= "Form1 ">
<div>
出发地: <input type= "text " size= "10 " maxlength= "10 " class= "url " id= "chufa " NAME= "chufa "/> &nbsp;&nbsp; 目的地: <input type= "text " size= "10 " maxlength= "10 " class= "url " id= "zhongdian " NAME= "zhongdian "/> <input type= "submit " value= "查询 " id= "sub " NAME= "sub "/>
</div>
</form>

那么
aspx文件中 可以用QueryString得到
private void Page_Load(object sender, System.EventArgs e)
{
Response.Write(Request.QueryString[ "zhongdian "]);

}
------解决方案--------------------
晕,
input的name属性等于zhongdian,而不是id.