注册 登录
编程论坛 ASP.NET技术论坛

提交表单出错。

gaohanxiong 发布于 2007-05-15 22:39, 738 次点击

表单页
<form method="post" action="default4.aspx">
<input id="Text1" type="text"/><br />

<input id="Text2" type="text" />
<br />
<input id="Submit1" type="submit" value="提交" />
</form>

处理页
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>

<!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 id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>
处理页 .cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string username = Request["Text1"].ToString();
string password = Request["Text2"].ToString();
// Response.Write("用户名:" + username + ";密码:" + password);
}
}
请问各位大虾,我到底哪里错了!!

9 回复
#2
gaohanxiong2007-05-16 08:20
各位大哥帮帮忙啦。。
#3
bygg2007-05-16 09:49
你的提交写在哪里的?
#4
gaohanxiong2007-05-16 20:06

提交到default4.aspx
处理页就是default4.aspx

#5
gaohanxiong2007-05-16 20:24

“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。

源错误:


行 14: protected void Page_Load(object sender, EventArgs e)
行 15: {
行 16: string username = Request["Text1"].ToString();
行 17: string password = Request["Text2"].ToString();
行 18: // Response.Write("用户名:" + username + ";密码:" + password);

#6
ahuinan2007-05-16 20:34



表单页
<form method=\"post\" action=\"default4.aspx\">
  <input id=\"Text1\" type=\"text\"/><br />


    <input id=\"Text2\" type=\"text\" />
    <br />
    <input id=\"Submit1\" type=\"submit\" value=\"提交\" />
  </form>


改成

<!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 action=\"default4.aspx\" method=\"post\">
  <input type=\"text\" name=\"Text1\"/><br />


    <input type=\"text\" name=\"Text2\"/>
    <br />
    <input id=\"Submit1\" type=\"submit\" value=\"提交\" />
  </form>



</body>
</html>

#7
rainic2007-05-16 21:42
不用加Body,Head,Html那些也行的


只是要在Input加个Name而已
#8
tel19822007-05-16 22:01

你的表单页在那里写着呢,在处理页面吗??

#9
gaohanxiong2007-05-17 20:40
回复:(ahuinan)将[code]表单页

还是不行。。。很郁闷!

编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: ASPNET: 请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如 Page 或 UserControl)是正确的。

源错误:

行 1: using System;
行 2: using System.Data;
行 3: using System.Configuration;

#10
gaohanxiong2007-05-17 20:40
刚学就受到这么大的挫折。。。
1