2011-02-16 117 views
0

我有一個問題,一直在推動我堅果。C#找不到類型或名稱空間名稱

我有2個ASPX頁面,其中父級使用Server.Transfer()函數。父被稱爲Submit.aspx而孩子被稱爲Review.aspx

在Submit.aspx.cs,我有:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 

public partial class Contacts_Submit : BasePage 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 

    } 
    protected void Review_Click(object sender, EventArgs e) 
    { 
     Server.Transfer("Review.aspx", true); 
    } 

    /* 
    * Sequence of functions that will server as a Get functionality that will 
    * return the text inside each textbox. 
    * These information will be used by "Review.aspx" to validate the 
    * information given by the user before final submission takes place. 
    */ 
    public string GetFirstName { get { return FirstName.Text; } } 
    public string GetLastName { get { return LastName.Text; } } 
    public string GetAddress { get { return Address.Text; } } 
    public string GetCountry { get { return Country.SelectedValue; } } 
    public string GetProvince { get { return Province.SelectedValue; } } 
    public string GetCity { get { return City.Text; } } 
    public string GetZipCode { get { return ZipCode.Text; } } 
    public string GetWorkPhone { get { return WorkPhone.Text; } } 
    public string GetMobilePhone { get { return MobilePhone.Text; } } 
    public string GetFax { get { return Fax.Text; } } 
    public string GetEmail { get { return Email.Text; } } 
    public string GetCompany { get { return Company.Text; } } 
    public string GetWebsite { get { return Website.Text; } } 
    public string GetRelationship { get { return Relationship.SelectedValue; } } 
} 

而在Review.aspx.cs,我有:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Data; 
using System.Configuration; 
using System.Collections; 
using System.Web.Security; 
using System.Web.UI.WebControls.WebParts; 
using System.Web.UI.HtmlControls; 

public partial class Contacts_Review : BasePage 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     if(PreviousPage != null) 
     { 
      Contacts_Submit prevpage = PreviousPage as Contacts_Submit; 
      //FirstName.Text = PreviousPage.GetFirstName; 
     } 
    } 
} 

問題是當我聲明「Contacts_Submit prevpage = PreviousPage as Contacts_Submit」。系統給我一個錯誤,說「無法找到類型或名稱空間名稱'Contacts_Submit'(你是否缺少using指令或程序集引用?)」。

我是ASP.NET和C#的初學者,任何人都可以幫助我嗎?謝謝你好。

回答

4

我覺得你只是想

Contacts_Submit prevpage = PreviousPage as Contacts_Submit; 

,而不是

Contacts_Submit prevpage = PreviousPage as System.Data.DataSet Contacts_Submit; 
0

Contacts_Submit不相關的數據集任何方式頁的類型和,所以你投無效。 刪除,它應該很好

+0

對不起,不更新代碼。實際上,我確實在System.Data中使用了兩種方法,也沒有使用它。但它仍然不起作用。這真是令人困惑 – Sammm 2011-02-17 04:13:32

相關問題