我是这样做的,但服务器始终取不到
html:
<form action= "queryzhan.aspx " name= "zhanzhan " method= "post ">
<div>
出发地: <input type= "text " size= "10 " maxlength= "10 " class= "url " id= "chufa " /> 目的地: <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 "/> 目的地: <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.