环境:VS05,aa页面传值到bb页面,两个页面在根目录下面没问题,在文件夹下面的两个页面就提示出错???aa.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="aa.aspx.cs" Inherits="aa" %><!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>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="下一页" /></div>
</form>
</body>
</html>aa.aspx.csusing 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 aa : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("bb.aspx");
} public string name
{
get
{
return this.TextBox1.Text;
}
}
}bb.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="bb.aspx.cs" Inherits="bb" %>
<%@ PreviousPageType VirtualPath="~/aa.aspx" %><!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>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
</form>
</body>
</html>
bb.aspx.csusing 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 bb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
aa AA;
AA = (aa)Context.Handler;
Label1.Text = AA.name;
}
}
}各位帮忙测试一下,aa、bb两个页面在根目录下面没问题,在文件夹下面就出错,本人试了n次不成功谢谢啦
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="下一页" /></div>
</form>
</body>
</html>aa.aspx.csusing 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 aa : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("bb.aspx");
} public string name
{
get
{
return this.TextBox1.Text;
}
}
}bb.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="bb.aspx.cs" Inherits="bb" %>
<%@ PreviousPageType VirtualPath="~/aa.aspx" %><!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>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
</form>
</body>
</html>
bb.aspx.csusing 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 bb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
aa AA;
AA = (aa)Context.Handler;
Label1.Text = AA.name;
}
}
}各位帮忙测试一下,aa、bb两个页面在根目录下面没问题,在文件夹下面就出错,本人试了n次不成功谢谢啦
--------------------------------------------------------------------------------编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: CS0115: “ASP.test_a_aspx.GetTypeHashCode()”: 没有找到适合的方法来重写源错误: 行 683:
行 684: [System.Diagnostics.DebuggerNonUserCodeAttribute()]
行 685: public override int GetTypeHashCode() {
行 686: return -1959869534;
行 687: }
源文件: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\mybbs\72f0d563\f38cbfcd\App_Web_a.aspx.fcfebddb.m8pr7ldh.0.cs 行: 685
经测试,放入子目录是没有问题的!2.
删除 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\mybbs 该文件夹,然后重试3.
确保你的类 aa bb 没有重复,并且 @Page 指令引用正确了
我马上测试一下,ok就回来结贴