asp.net为何无法获得Request的值
第一个页面叫WriteMsg.aspx
网页的代码如下
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WriteMsg.aspx.cs" Inherits="Student_WriteMsg" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form name="form1" method="post" action="MsgSave.aspx">
<table style="width: 626px">
<tr>
<td style="width: 589px">
接收人</td>
<td style="width: 100px">
<input id="RecID" type="text" />
<input id="RecName" type="text" />
<input id="RecType" type="text" />
<td>
</tr>
<tr>
<td style="width: 589px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 589px; height: 94px">
标题</td>
<td style="width: 100px; height: 94px">
<textarea id="TextArea1" style="width: 555px; height: 212px"></textarea></td>
</tr>
<tr>
<td style="width: 589px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 589px">
</td>
<td style="width: 100px">
<input id="File1" style="width: 445px" type="file" /></td>
</tr>
<tr>
<td style="width: 589px">
</td>
<td style="width: 100px">
<input id="Submit1" type="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
将页面内容提交到MsgSave.aspx
该没有什么具体内容,在他的onpage_load事件中
public partial class Pub_MsgSave : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("RecID="+Request.Form["RecID"]);
}
}
为什么只能输出"RecID="而里面的值没有呢
前一页确实有值的
------解决方案--------------------
<input id="RecID" type="text" />
必须设置name属性,因为Request.Form是以name而不是id来区分的,修改为:
HTML code
<input id="RecID" name="RecID" type="text" />