我无法在aspx.cs页面上的intelliSense中找到命名空间 [英] I am not able to find the namespace in intelliSense on aspx.cs page

查看:74
本文介绍了我无法在aspx.cs页面上的intelliSense中找到命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在Connection.cs类中创建了以下命名空间。



使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Web;

使用System.Data;

使用System.Configuration;

使用System.Web.Security ;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System.Web.UI.WebControls。 WebParts;

使用System.Web.UI.HtmlControls;

使用System.Data.SqlClient;



命名空间conn

{

公共类连接

{

public SqlConnection con;

public SqlCommand cmd;

// public SqlDataAdapter adt;



string StrError;



公共连接()

{

尝试

{

con = new SqlConnection(ConfigurationManager。的ConnectionStrings [ PortfolioMgt]。Connectio nString);

}

catch(SqlException sqlEx)

{

StrError = sqlEx.Message;

}

catch(例外情况)

{

StrError = ex.Message;

}

}



public void Open_Connection()

{

try

{

con.Open();

}

catch(SqlException sqlEx)

{

StrError = sqlEx.Message;

}

catch(例外情况)

{

StrError = ex.Message;

}

}

public void Close_Connection()

{

试试

{

con.Close();

}

catch(SqlException sqlEx)

{

StrError = sqlEx .Message;

}

catch(exception ex)

{

StrError = ex.Message;

}

}

}

}





我想在Login.aspx.cs页面上使用自定义命名空间(conn)。登录页面的代码如下:





Hello I have created below namespace in Connection.cs class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
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.Data.SqlClient;

namespace conn
{
public class Connection
{
public SqlConnection con;
public SqlCommand cmd;
//public SqlDataAdapter adt;

string StrError;

public Connection()
{
try
{
con = new SqlConnection(ConfigurationManager.ConnectionStrings["PortfolioMgt"].ConnectionString);
}
catch (SqlException sqlEx)
{
StrError = sqlEx.Message;
}
catch (Exception ex)
{
StrError = ex.Message;
}
}

public void Open_Connection()
{
try
{
con.Open();
}
catch (SqlException sqlEx)
{
StrError = sqlEx.Message;
}
catch (Exception ex)
{
StrError = ex.Message;
}
}
public void Close_Connection()
{
try
{
con.Close();
}
catch (SqlException sqlEx)
{
StrError = sqlEx.Message;
}
catch (Exception ex)
{
StrError = ex.Message;
}
}
}
}


I wanted to use a customized namespace(conn) on Login.aspx.cs page. The code for Login page is as below:


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.Data.SqlClient;
using conn;

public partial class Login : System.Web.UI.Page
{
    Connection con = new Connection();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        int investorId;
        investorId=con.select_Inv_Login(txtUserName.Text, txtPassword.Text);

        if(investorId!=0)
        {
            Session["inv_id"] = investorId;
            Response.Redirect("~/MyProfile.aspx");
        }
        else
        {
            lblMsg.Visible = true;
            lblMsg.Text = "User Name or Password incorrect";
        }
    }
}



Once I try to write 'using conn;' it gave me below error:
The type or namespace name 'conn' could not be found (are you missing a using directive or an assembly reference?)

推荐答案

引用:

检查你的类构建操作是否设置为Compile(右键单击你的类在解决方案资源管理器中并单击属性)。

Check if your classes build action is set to Compile (right click on your class in solution explorer and click properties).



参考: VS2010中App_Code中的Intellisense [ ^ ]


这篇关于我无法在aspx.cs页面上的intelliSense中找到命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆