初学asp.net,request怎么获取不到数据?详细如下:
起始页是一个html文件,代码如下:
<!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>
<title>无标题页</title>
</head>
<body>
<form method="post"action="Default.aspx" style="background-color: olive" >
<hr style="z-index: 101; left: 24px; position: absolute; top: 432px" />
sdfsdf<input id="Submit1" style="left: 448px; position: relative; top: 0px"
type="submit" value="submit" />
<input id="Text1" style="left: -22px; position: relative; top: 0px" type="text" />
<input id="Text2" style="position: relative" type="text" />
</form>
</body>
</html>
接收数据为一个axpx页面,代码如下:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim str, pwd As String
str = Request("Text1").ToString
str = Request("Text2").ToString
Response.Write("登录用户名为" + str + " ;密码为" + pwd)
End Sub
End Class
一提交就出现“用户代码未处理NULLReferenceException,未将对象引用设置到对象的实例。”这样的错误。
上面这些代码我是按照教程做的,唯一不同的就是教程用的vs2003我用的是vs2005。请大家帮帮忙!