请教大家个问题:错误显示"未将对象引用设置到对象的实例"第16行显示错误,怎么改正?行 14:     protected void Page_Load(object sender, EventArgs e)
行 15:     {行 16:         this.pp_TextBox = (TextBox)PreviousPage.FindControl("TextBox1");行 17:         this.pp_Calendar = (Calendar)PreviousPage.FindControl("Calendar1"); 

解决方案 »

  1.   

    看一下你页面的textbox的ID是不是pp_TextBox 
      

  2.   

    确认PreviousPage.FindControl("TextBox1")语句能否正常提取上一页的控件,最好加入是否为null的判断
      

  3.   

    PreviousPage在此处应该都已经被销毁了吧……
    设个断点,看看PreviousPage是不是已经是NULL了
    要引用这个PreviousPage的控件,就让PreviousPage的Visible为false
    可否?
      

  4.   

    你们说得没错,先前页是为空,但以我已在当前页中加上"<%@ PreviousPageType VirtualPath="~/Default.aspx" %>"了,不知为什么?
      

  5.   

    if(PreviousPage != null)
    {
    this.pp_TextBox = (TextBox)PreviousPage.FindControl("TextBox1");this.pp_Calendar = (Calendar)PreviousPage.FindControl("Calendar1"); 
    }
      

  6.   

           我明白了,原来在Default.aspx中用了 Response.Redirect,而 Response.Redirect是使用浏览器将用户重定向到另一页,而应该用Server.Transfe,使用服务器端方法将用户重定向到另一页.
            不过还是谢谢大家帮助.谢谢~