ASP.NET 2.0中关开IsCrossPagePostBack属性的问题
今天在看《ASP.NET 2.0高级编程(第4版)》第3章第3.6节-跨页面的传送时,尝试使用Page属性IsCrossPagePostBack时发现无论如何都无法访问page2.aspx,代码如下:
搞不懂是怎么回事。。。后来使用以下代码使现了同样的功能:
if (IsCrossPagePostBack)
{
Label1.Text = "Hello " + PreviousPage.pp_TextBox.Text + "<br> " + "Date Selected: " + PreviousPage.pp_Calendar.SelectedDate.ToShortDateString();
}
else
{
Response.Redirect("page1.aspx");
}
{
Label1.Text = "Hello " + PreviousPage.pp_TextBox.Text + "<br> " + "Date Selected: " + PreviousPage.pp_Calendar.SelectedDate.ToShortDateString();
}
else
{
Response.Redirect("page1.aspx");
}
搞不懂是怎么回事。。。后来使用以下代码使现了同样的功能:
if (PreviousPage != null)
{
Label1.Text = "Hello " + PreviousPage.pp_TextBox.Text + "<br> " + "Date Selected: " + PreviousPage.pp_Calendar.SelectedDate.ToShortDateString();
}
else
{
Response.Redirect("page1.aspx");
}
{
Label1.Text = "Hello " + PreviousPage.pp_TextBox.Text + "<br> " + "Date Selected: " + PreviousPage.pp_Calendar.SelectedDate.ToShortDateString();
}
else
{
Response.Redirect("page1.aspx");
}