菜鸟问题?(它困惑我好久了)

c953131 2003-08-18 09:57:52
我有一个框架网页:
WebForm1.aspx
<%@ Page %>
<HTML>
<HEAD>
<TITLE>WebForm1</TITLE>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<frameset rows="*" cols="184,*" framespacing="1" frameborder="no" border="0">
<frame src="WebForm2.aspx" name="leftFrame" scrolling="yes" noresize>
<frame src="WebForm3.aspx" name="mainFrame">
</frameset>
</HTML>

WebForm2.aspx
<%@ Page %>
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language=javascript>
function change_form()
{
//alert("form_search存在吗?" + document.form_search)
document.Form1.action="WebForm3.aspx";
document.Form1.target="mainFrame";
}
function check_form()
{
var search_date=document.Form1.TextBox1.value;
if (search_date=="")
{
alert("日期不能为空");
document.Form1.TextBox1.focus();
return false;
}
return true;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server" action="WebForm2.aspx" target=leftFrame onsubmit="return check_form();">
<table cellspacing="1" cellpadding="5" width="300" border="0">
<tr>
<td>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>
<input class="button" onclick="javascript:change_form()" type="submit" value="SUMBIT" name="Submit"></td>
</tr>
<tr>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="不能为空!" Display="None"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:ValidationSummary id="ValidationSummary1" runat="server" DisplayMode="List" ShowMessageBox="True"
ShowSummary="False"></asp:ValidationSummary></td>
</tr>
</table>
</form>
</body>
</HTML>

WebForm3.aspx
<%@ Page %>
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"></FONT>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</form>
</body>
</HTML>


问题在于:
WebForm2.aspx中的语句块上,
function change_form()
{
document.Form1.action="WebForm3.aspx";
document.Form1.target="mainFrame";
}
在如上语句中,进行调试时,
1、如果我在两句中少了其中一对双引号:document.Form1.action="WebForm3.aspx";document.Form1.target="mainFrame";
会出现WebForm3未定义,或是mainFrame未定义

2、如果都有引号
document.Form1.action="WebForm3.aspx";document.Form1.target="mainFrame";
它老是提示我:
“/fjcb”应用程序中的服务器错误。
--------------------------------------------------------------------------------

此页的视图状态无效,可能已损坏。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Web.HttpException: 此页的视图状态无效,可能已损坏。

源错误:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。

堆栈跟踪:


[HttpException (0x80004005): 此页的视图状态无效,可能已损坏。]
System.Web.UI.Page.LoadPageStateFromPersistenceMedium()
System.Web.UI.Page.LoadPageViewState()
System.Web.UI.Page.ProcessRequestMain()




--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:1.1.4322.573; ASP.NET 版本:1.1.4322.573

请问这是怎么回事,谢谢!(急)
...全文
18 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2003-08-18
  • 打赏
  • 举报
回复
the recommended way is to either save the data on the server side and use Response.Redirect or use Server.Transfer

but if you insist, try to add this line in WebForm3.aspx

<%@ Page EnableViewStateMac="false" %>
wixwiz 2003-08-18
  • 打赏
  • 举报
回复
function change_form()
{
document.Form1.location="WebForm3.aspx";
document.Form1.target="mainFrame";
}
c953131 2003-08-18
  • 打赏
  • 举报
回复
那不是说得把那些WEB的控件改为HTML的了
dmn 2003-08-18
  • 打赏
  • 举报
回复
错误原因是:若WebForm2.aspx中的form表单的runat属性设为server,则此表单一旦提交到其它面就会出现上述错误。也就是说若某个form设置了runat=server,那么这个form就不能提交到其它页面。

这样,你只需要去掉WebForm2.aspx中form的runat属性就可以。

但问题是如果这样做,而且你又可能在某个时候提交到WebForm2.aspx页面本身的时候,则WebForm2的后台代码中就不能用IsPostBack来做判断了,当然也可能影响WebForm2.aspx上的服务器控件。因此你得权衡一下。

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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