从头学ASP.NET,教材实例也没编译通过,请朋友们指点。

自由程序员
C#领域优质创作者
博客专家认证
2007-11-28 01:36:16
这是出错提示:

Error 1 Validation (XHTML 1.1): Element 'p' is missing its closing tag. f:\Design Pattern\WebSite3\Default.aspx 15 10 f:\Design Pattern\WebSite3\
Error 2 Validation (XHTML 1.1): Element 'p' cannot be nested within element 'p'. f:\Design Pattern\WebSite3\Default.aspx 31 10 f:\Design Pattern\WebSite3\
Error 3 Validation (XHTML 1.1): Element 'h2' cannot be nested within element 'p'. f:\Design Pattern\WebSite3\Default.aspx 40 10 f:\Design Pattern\WebSite3\
Error 4 Validation (XHTML 1.1): Element 'p' cannot be nested within element 'p'. f:\Design Pattern\WebSite3\Default.aspx 41 10 f:\Design Pattern\WebSite3\
Error 5 The server tag is not well formed. f:\Design Pattern\WebSite3\Default.aspx 46

这是源码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_Default" %>

<!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 id="Head1" runat="server">
<title>Validation Groups</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>St. Louis .NET User Group</h1>
<p>Username:
<asp:TextBox ID="TextBox1" Runat="server"></asp:TextBox>  Password:
<asp:TextBox ID="TextBox2" Runat="server"
TextMode="Password"></asp:TextBox> 
<asp:Button ID="Button1" Runat="server" Text="Login"
ValidationGroup="Login" />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server"
ErrorMessage="* You must submit a username!"
ControlToValidate="TextBox1" ValidationGroup="Login" >
</asp:RequiredFieldValidator>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server"
ErrorMessage="* You must submit a password!"
ControlToValidate="TextBox2" ValidationGroup="Login" >
</asp:RequiredFieldValidator>
<p>
Our main meeting is almost always held on the last Monday of the month.
Sometimes due to holidays or other extreme circumstances,
we move it to another night but that is very rare. Check the home page
of the web site for details. The special
interest groups meet at other times during the month. Check the SIG
page and visit their individual sites for more information.
You can also check our calendar page for a summary of events.<br />
</p>
<h2>Sign-up for the newsletter!</h2>
<p>Email:
<asp:TextBox ID="TextBox3" Runat="server"></asp:TextBox> 
<asp:Button ID="Button2" Runat="server" Text="Sign-up"
ValidationGroup="Newsletter" /> 
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
Runat="server"
ErrorMessage="* You must submit a correctly formatted email address!"
ControlToValidate="TextBox3"ValidationGroup="Newsletter"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" Runat="server"
ErrorMessage="* You forgot your email address!"
ControlToValidate="TextBox3" ValidationGroup="Newsletter">
</asp:RequiredFieldValidator>
</p>
</div>
</form>
</body>
</html>
...全文
110 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
自由程序员 2007-11-28
  • 打赏
  • 举报
回复
真的是空格惹的祸。再次,受到此类教育。结贴了。
zj1989 2007-11-28
  • 打赏
  • 举报
回复
对了,<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
Runat="server"
ErrorMessage="* You must submit a correctly formatted email address!"
ControlToValidate="TextBox3"ValidationGroup="Newsletter"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">

中间得有一个空格ControlToValidate="TextBox3" ValidationGroup="Newsletter"
自由程序员 2007-11-28
  • 打赏
  • 举报
回复
晕啊。难道是windows 2003的问题?
zj1989 2007-11-28
  • 打赏
  • 举报
回复
我用的也是2005 把你的代码贴过去 加上</p>都编译过去了啊。不知道了
自由程序员 2007-11-28
  • 打赏
  • 举报
回复
Error 5 The server tag is not well formed.
似乎这个的问题
自由程序员 2007-11-28
  • 打赏
  • 举报
回复
我这儿编译不通过,用的是vs2005英文版,windows 2003 英文版。出错提示,如前面所贴。
zj1989 2007-11-28
  • 打赏
  • 举报
回复
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_Default" %>

<!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 id="Head1" runat="server">
<title> Validation Groups </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1> St. Louis .NET User Group </h1>
<p> Username:



Username: 后面少了</p>
zhanghy1028 2007-11-28
  • 打赏
  • 举报
回复
但是好像并不影响啊
zhanghy1028 2007-11-28
  • 打赏
  • 举报
回复
说明有一个<P>标签没有关闭
是第一个
在第二个前加个</p>就好了
自由程序员 2007-11-28
  • 打赏
  • 举报
回复
这是源码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_Default" %>

<!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 id="Head1" runat="server">
<title> Validation Groups </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1> St. Louis .NET User Group </h1>
<p> Username:
<asp:TextBox ID="TextBox1" Runat="server"> </asp:TextBox>   Password:
<asp:TextBox ID="TextBox2" Runat="server"
TextMode="Password"> </asp:TextBox>  
<asp:Button ID="Button1" Runat="server" Text="Login"
ValidationGroup="Login" />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server"
ErrorMessage="* You must submit a username!"
ControlToValidate="TextBox1" ValidationGroup="Login" >
</asp:RequiredFieldValidator>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server"
ErrorMessage="* You must submit a password!"
ControlToValidate="TextBox2" ValidationGroup="Login" >
</asp:RequiredFieldValidator>
<p>
Our main meeting is almost always held on the last Monday of the month.
Sometimes due to holidays or other extreme circumstances,
we move it to another night but that is very rare. Check the home page
of the web site for details. The special
interest groups meet at other times during the month. Check the SIG
page and visit their individual sites for more information.
You can also check our calendar page for a summary of events. <br />
</p>
<h2> Sign-up for the newsletter! </h2>
<p> Email:
<asp:TextBox ID="TextBox3" Runat="server"> </asp:TextBox>  
<asp:Button ID="Button2" Runat="server" Text="Sign-up"
ValidationGroup="Newsletter" />  
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
Runat="server"
ErrorMessage="* You must submit a correctly formatted email address!"
ControlToValidate="TextBox3"ValidationGroup="Newsletter"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" Runat="server"
ErrorMessage="* You forgot your email address!"
ControlToValidate="TextBox3" ValidationGroup="Newsletter">
</asp:RequiredFieldValidator>
</p>
</div>
</form>
</body>
</html>
qawszx 2007-11-28
  • 打赏
  • 举报
回复
哦,发现了
ControlToValidate="TextBox3"ValidationGroup="Newsletter"

这句在ValidationGroup前面少了一个空格,改为
ControlToValidate="TextBox3" ValidationGroup="Newsletter"
flybird_13 2007-11-28
  • 打赏
  • 举报
回复
1 p标签没有闭合
2 p标签不能嵌套使用
qawszx 2007-11-28
  • 打赏
  • 举报
回复
怎么了,我这里没事啊。
自由程序员 2007-11-28
  • 打赏
  • 举报
回复
这是源码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="default.aspx.cs" Inherits="_Default" %>

<!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 id="Head1" runat="server">
<title> Validation Groups </title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1> St. Louis .NET User Group </h1>
<p> Username:
<asp:TextBox ID="TextBox1" Runat="server"> </asp:TextBox>   Password:
<asp:TextBox ID="TextBox2" Runat="server"
TextMode="Password"> </asp:TextBox>  
<asp:Button ID="Button1" Runat="server" Text="Login"
ValidationGroup="Login" />
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server"
ErrorMessage="* You must submit a username!"
ControlToValidate="TextBox1" ValidationGroup="Login" >
</asp:RequiredFieldValidator>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server"
ErrorMessage="* You must submit a password!"
ControlToValidate="TextBox2" ValidationGroup="Login" >
</asp:RequiredFieldValidator>
<p>
Our main meeting is almost always held on the last Monday of the month.
Sometimes due to holidays or other extreme circumstances,
we move it to another night but that is very rare. Check the home page
of the web site for details. The special
interest groups meet at other times during the month. Check the SIG
page and visit their individual sites for more information.
You can also check our calendar page for a summary of events. <br />
</p>
<h2> Sign-up for the newsletter! </h2>
<p> Email:
<asp:TextBox ID="TextBox3" Runat="server"> </asp:TextBox>  
<asp:Button ID="Button2" Runat="server" Text="Sign-up"
ValidationGroup="Newsletter" />  
<br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
Runat="server"
ErrorMessage="* You must submit a correctly formatted email address!"
ControlToValidate="TextBox3"ValidationGroup="Newsletter"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">
</asp:RegularExpressionValidator>
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" Runat="server"
ErrorMessage="* You forgot your email address!"
ControlToValidate="TextBox3" ValidationGroup="Newsletter">
</asp:RequiredFieldValidator>
</p>
</div>
</form>
</body>
</html>

62,047

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧