C#找不到类型或命名空间名称

时间:2011-02-16 03:59:13

标签: c# namespaces types .net-assembly directive

我有一个让我疯狂的问题。

我有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#的初学者,任何人都可以帮助我吗?谢谢SOOO MUCH。

2 个答案:

答案 0 :(得分:4)

我想你只想要

Contacts_Submit prevpage = PreviousPage as Contacts_Submit;

而不是

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

答案 1 :(得分:0)

Contacts_Submit是Page的类型,与数据集无任何关联,因此您的演员表无效。 删除它,它应该没问题