环境:Visual Studio 2008
语言:C#
程序:ASP.NET 我新建了一个母版页文件,前台代码如下:<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %><!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>
<script language="javascript">
function showtime(time)
{
var now= new Date();
years = now.getFullYear();
month = now.getMonth()+1;
dates = now.getDate();
hours = now.getHours();
Minutes = now.getMinutes();
Seconds = now.getSeconds();
if (hours<10)
hours="0"+hours;
if(Minutes<10)
Minutes="0"+Minutes;
if (Seconds<10)
Seconds="0"+Seconds;
var titletext = "";
titletext=years + "年" + month + "月" + dates + "日" +hours +":" + Minutes + ":" + Seconds;
var timer=setTimeout("showtime()",1000);
if(document.all){
time.innerHTML="今天是:"+titletext+"";
}
}
</script>
</head>
<body onload="showtime(time);">
<form id="form1" runat="server">
<div>
<table border="1" style="width:100%; height:100% ">
<tr>
<td colspan="2" align="center">
<img src="images/img01.jpg"/>
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%">
<tr>
<td align="left"style="width:30%">
<div id="time"></div>
</td>
<td align="right"style="width:50%">
您现在的身份是普通游客!请注册成会员!
</td>
<td align="right" style="width:20%">
<asp:Button ID="Button2" runat="server" Text="Button" Width="41px" />
<asp:Button ID="Button1" runat="server" Text="Button" Width="41px" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" style="width:20%">
<a href="Default.aspx">站长主页</a><p/>
<a href="Computer.aspx">加为好友</a><p/>
<a href="#">好友空间</a>
</td>
<td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td colspan="2" align="center">
©2007 myBookroom
</td>
</tr>
</table>
</div>
</form>
</body>
</html>把它应用到普通文件之后运行,程序给出如下运行错误提示:“/深蓝火焰个人网站”应用程序中的服务器错误。
--------------------------------------------------------------------------------一页只能有一个服务器端 Form 标记。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 一页只能有一个服务器端 Form 标记。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
在这里我不明白,我的代码里明明只放了一个<form></form>标签啊,怎么会有这样的错误提示。谁能告诉我到底哪出了问题?
该如何修改代码?谢谢!!直觉上我认为如下2句代码有问题:<asp:Button ID="Button2" runat="server" Text="Button" Width="41px" />
<asp:Button ID="Button1" runat="server" Text="Button" Width="41px" />
可我看不出问题再哪,谁能告诉我?谢谢!
语言:C#
程序:ASP.NET 我新建了一个母版页文件,前台代码如下:<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %><!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>
<script language="javascript">
function showtime(time)
{
var now= new Date();
years = now.getFullYear();
month = now.getMonth()+1;
dates = now.getDate();
hours = now.getHours();
Minutes = now.getMinutes();
Seconds = now.getSeconds();
if (hours<10)
hours="0"+hours;
if(Minutes<10)
Minutes="0"+Minutes;
if (Seconds<10)
Seconds="0"+Seconds;
var titletext = "";
titletext=years + "年" + month + "月" + dates + "日" +hours +":" + Minutes + ":" + Seconds;
var timer=setTimeout("showtime()",1000);
if(document.all){
time.innerHTML="今天是:"+titletext+"";
}
}
</script>
</head>
<body onload="showtime(time);">
<form id="form1" runat="server">
<div>
<table border="1" style="width:100%; height:100% ">
<tr>
<td colspan="2" align="center">
<img src="images/img01.jpg"/>
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%">
<tr>
<td align="left"style="width:30%">
<div id="time"></div>
</td>
<td align="right"style="width:50%">
您现在的身份是普通游客!请注册成会员!
</td>
<td align="right" style="width:20%">
<asp:Button ID="Button2" runat="server" Text="Button" Width="41px" />
<asp:Button ID="Button1" runat="server" Text="Button" Width="41px" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="right" style="width:20%">
<a href="Default.aspx">站长主页</a><p/>
<a href="Computer.aspx">加为好友</a><p/>
<a href="#">好友空间</a>
</td>
<td>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
<td colspan="2" align="center">
©2007 myBookroom
</td>
</tr>
</table>
</div>
</form>
</body>
</html>把它应用到普通文件之后运行,程序给出如下运行错误提示:“/深蓝火焰个人网站”应用程序中的服务器错误。
--------------------------------------------------------------------------------一页只能有一个服务器端 Form 标记。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 一页只能有一个服务器端 Form 标记。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。
在这里我不明白,我的代码里明明只放了一个<form></form>标签啊,怎么会有这样的错误提示。谁能告诉我到底哪出了问题?
该如何修改代码?谢谢!!直觉上我认为如下2句代码有问题:<asp:Button ID="Button2" runat="server" Text="Button" Width="41px" />
<asp:Button ID="Button1" runat="server" Text="Button" Width="41px" />
可我看不出问题再哪,谁能告诉我?谢谢!
这样肯定不会出现这们的错误:
异常详细信息: System.Web.HttpException: 一页只能有一个服务器端 Form 标记。
出现其它的错误是什么错误,说说
</asp:ContentPlaceHolder> 删了试下
XXXXX必须放在具有 runat=server 的窗体标记内.
还有就是引用母版页的ASPX文件中的内容是否放在ContentPlaceHolder中
新建的页面里不要 form 标签的
这样肯定不会出现这们的错误:
异常详细信息: System.Web.HttpException: 一页只能有一个服务器端 Form 标记。
出现其它的错误是什么错误,说说
正解(貌似引用不能用了)
就是删除 母板的页面的form
</asp:ContentPlaceHolder>内加载的page去掉form
页面代码内
<asp:Content D="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"></asp:Content>里面估计LZ加了<from>标签了又