// SourcePage.aspx
public partial class SourcePage: System.Web.UI.Page
{
protected void btnSearch_Click(object sender, EventArgs e)
{
//......
//......
while (rdr.Read())
{
txtName.Text = rdr["Name"].ToString();
}
rdr.Close();
}
public string GetName
{
get { return txtName.Text; }
}
protected void btnServer.Transfer_Click1(object sender, EventArgs e)
{
Server.Transfer("TargetPage1.aspx");
Server.Transfer("TargetPage2.aspx");
}
}
//TargetPage1.aspx
protected void Page_Load(object sender, EventArgs e)
{
SourcePage SP;
SP = (SourcePage)Context.Handler; // I get runtime error here: unable to cast object of type 'ASP.TargetPage_aspx' to type 'SourcePage'
txtTPName.Text = p.GetName;
}
我哪里错了?实在想不通。我需要将值从源页面传输到其他目标页面,并且我不想使用多个查询。任何形式的帮助将不胜感激!