本帖最后由 horselifegood 于 2010-09-10 16:28:58 编辑

解决方案 »

  1.   

    Default form1 =(PreviousPage as Default)Context.Handler
      

  2.   

    在第二个页面中,这里Default form1 =(PreviousPage as Default)Context.Handler没办法看到Default呀!是不是加Using什么的?
      

  3.   

    是很搞笑的类名错误
    public partial class _Default : System.Web.UI.Page类名是_Default,不是Default把default2.aspx中的代码改成下面的试试看
    _Default form1 =(_Default)Context.Handler;//PreviousPage as
    Response.Write(form1.UserName);
      

  4.   

    protected System.Web.UI.WebControls.TextBox TextBox1;  
    private void Page_Load(object sender, System.EventArgs e)  
    {  
    Context.Items.Add("Context","Form1");  
    }  
    public string Time  
    {  
    get{return DateTime.Now.ToString();}  
    }  
    public string Test()  
    {  
    return "Test";  
    }  public class WebForm2 : System.Web.UI.Page  
    {  
    protected System.Web.UI.WebControls.Literal Literal1;  private void Page_Load(object sender, System.EventArgs e)  
    {  
    string strTxt="";  
    WebForm1 web1=(WebForm1)this.Context.Handler;  
    strTxt+="Value of Textbox:"+Request.Form["TextBox1"] +"<br>";  
    strTxt+="Time Property:"+web1.Time +"<br>";  
    strTxt+="Context String:"+Context.Items["Context"].ToString() +"<br>";  
    strTxt+=web1.Test() +"<br>";  
    Literal1.Text =strTxt;  
    }