0

我有一个从“Login.aspx”页面的 btnContinue_Click 事件调用的 Employee 类对象。我无法看到智能感知中的任何属性。Employee.cs 文件与 Web 应用程序位于同一项目中。令我困惑的是,aspx.cs 识别Employee oEmp = new Employee();得非常好。

我在下面的代码中做错了什么?

这是我的代码:
employee.cs

public class Employee
{
    public string FirstName  { get; set; }
    public string LastName { get; set; }
    public string DateOfBirth { get; set; }
    public string EMailAddress { get; set; }
    public string PhoneNumber { get; set; }
    public string CorpID { get; set; }
    public string SignOn { get; set; }
    public string Password { get; set; }
}  

登录.aspx.cs

    protected void btnEmployeeLogin_Click(object sender, EventArgs e)
    {
        try
        {
            if (LogInValidated())
            {
                Employee oEmp = new Employee();
                //oEmp.
            }
        }

        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
4

4 回答 4

2

听起来 Visual Studios 认为 oEmp 是 .aspx 页面上的控件,而不是类的类型Employee。您是否仔细检查了您的 .aspx 页面以确保您没有使用它的控件ID="oEmp"and runat="server"

或者您确定您的解决方案中没有Employee.ascx文件?

于 2012-07-05T17:42:52.590 回答
0

在页面顶部,您可以添加:

using **here the package of your employee class**;
于 2012-07-05T17:40:34.357 回答
0

确保 Customer 类与 btnCustomerLogin_Click 事件位于相同的命名空间中。如果它不在类的顶部包含 using 语句。

如果您使用的是 Visual Studio,只需单击 Employee 对象并按Ctrl+'。并从那里选择命名空间。

于 2012-07-05T17:42:50.603 回答
0

移动 Employee.cs 文件,使其位于 App_Code 下。这应该使 VS 识别该类。

如果您还没有 App_Code 文件夹,请通过以下方式添加:

  • 在 VS 解决方案资源管理器中右键单击网站
  • App_Code在“ ”下选择“ Add Asp.net folder

不要只添加一个名为 App_Code 的“常规”文件夹。

于 2012-07-05T17:58:54.720 回答