我有两个页面,a.htm,b.aspx.在a.htm上有两textBox(txtuserName,txtUserPwd)和一button,现我想点提交button时,在b.aspx上结收userName和userPwd,
代码如下:
string UserName = Request["txtUserName"] != null ? Request["txtUserName"].ToString() : string.Empty;
string UserPwd = Request["txtUserPwd"] != null ? Request["txtUserPwd"].ToString() : string.Empty;Response.Write("用户名是:" + UserName + "<br>密码是:" + UserPwd);
为什么当我提交的时候,什么都得不到呢?也就是得不到userName和UserPwd的值.(用post方式提交)
(不管我在a.htm的textbox上有没有输入值,得到的都是nothing,另,是在vs2005中,我在2003中是可以做到的,为什么会这样子啊?刚用05不久)
代码如下:
string UserName = Request["txtUserName"] != null ? Request["txtUserName"].ToString() : string.Empty;
string UserPwd = Request["txtUserPwd"] != null ? Request["txtUserPwd"].ToString() : string.Empty;Response.Write("用户名是:" + UserName + "<br>密码是:" + UserPwd);
为什么当我提交的时候,什么都得不到呢?也就是得不到userName和UserPwd的值.(用post方式提交)
(不管我在a.htm的textbox上有没有输入值,得到的都是nothing,另,是在vs2005中,我在2003中是可以做到的,为什么会这样子啊?刚用05不久)
htm页面有没有action="***.aspx" method="post"这句
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<form action="Default.aspx" method="post">
<table border=0 cellpadding=0 cellspacing=0 style="left: 95px; width: 300px; position: relative; top: 38px; height: 155px">
<tr>
<td style="width: 175px" align="left">
用户名:</td>
<td style="width: 381px">
<input id="txtUserName" type="text" /></td>
</tr>
<tr>
<td style="width: 175px">
密 码:</td>
<td style="width: 381px">
<input id="txtUserPwd" type="text" /></td>
</tr>
<tr >
<td colspan="2" align="center" valign="top">
<input id="Submit1" type="submit" value="提交" /></td>
</tr>
</table>
</form>
</body>
</html>b.aspx是:
protected void Page_Load(object sender, EventArgs e)
{ string UserName = Request.Form.Get("txtUserName") != null ? Request.Form["txtUserName"].ToString() : string.Empty;
string UserPwd = Request["txtUserPwd"] != null ? Request["txtUserPwd"].ToString() : string.Empty;
Response.Write("用户名是:" + UserName + "<br>密码是:" + UserPwd);
}