ASP.net怎么访问不了一个类?请指点!
这是我先建的一个类里面写的代码:.CS页面
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
/// <summary>
/// Class2 的摘要说明
/// </summary>
namespace ExporClass
{
public class Class2
{
public Class2()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public void aaa()
{
//...
}
}
}
我在窗体里.aspx的代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Windows.Forms;
using System.ComponentModel;
using System.Text;
public partial class Default2 : System.Web.UI.Page
{
//这里我应该 Class2 aa = new Class2();
//aa.aaa(); 可是访问不了?
protected void Page_Load(object sender, EventArgs e)
{
//aaa();
}
}
请高手指点在线等!
------解决方案--------------------ExporClass.Class2 aa = new ExporClass.Class2();
aa.aaa();
------解决方案--------------------或者在你的Default2.aspx的CS文件里添加引用
------解决方案--------------------把你的Class2放到App_Code目录里
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ExporClass.Class2 aa = new ExporClass.Class2();
aa.aaa();
}
}
------解决方案--------------------namespace ExporClass
{
public partial class Default2 : System.Web.UI.Page
{
//这里我应该 Class2 aa = new Class2();
//aa.aaa(); 可是访问不了?
protected void Page_Load(object sender, EventArgs e)
{
//aaa();
}