C# ASP.NET:插入';名称空间';

C# ASP.NET:插入';名称空间';,c#,mysql,asp.net,visual-studio-2012,visual-studio-2013,C#,Mysql,Asp.net,Visual Studio 2012,Visual Studio 2013,嘿,我在使用MySQL数据库实现注册页面时遇到了问题。当我在页面的代码中插入“namespace localhost_54355”时,我的按钮、文本框、面板将无法识别。但是当我删除“名称空间”时,按钮变得可用,但我的类DBRoutines无法识别。你能帮我找出这个问题吗 谢谢 注: 这里的变量'DBRoutines.Insert.Addcompany(TextUserName.Text、txtCo_JobPosition.Text、txtCo_JobPosition description.Te

嘿,我在使用MySQL数据库实现注册页面时遇到了问题。当我在页面的代码中插入“namespace localhost_54355”时,我的按钮、文本框、面板将无法识别。但是当我删除“名称空间”时,按钮变得可用,但我的类DBRoutines无法识别。你能帮我找出这个问题吗

谢谢

注: 这里的变量'DBRoutines.Insert.Addcompany(TextUserName.Text、txtCo_JobPosition.Text、txtCo_JobPosition description.Text、txtCo_Email.Text、int.Parse(txtCo_Phone.Text)、txtCo_Address.Text);'这是不对的。唯一正确的是“TextUserName.Text”,但它仍然只有在我删除“namespace”时才能被识别


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace localhost_54355
{

    public partial class UI : System.Web.UI.Page
    {


        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Server=PC\\SQLEXPRESS;Data Source=dbo\\EmployeeDatabase;Integrated Security=True;");
            SqlCommand cmd = new SqlCommand("INSERT INTO TableEmployees(UserName,Email,Password,Job,FirstName,LastName,Location,Phone) VALUES (sdfsd,sdfsdfds, 123456, xcvxcv, xcvxcvcxvx, dfgdfgd, cvbcbcbcb, 123645);", con);

            cmd.CommandType = CommandType.Text;

            try
            {
                con.Open();

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.ToString());
            }
            finally
            {
                con.Close();
            }
        }


        protected void Button1_Click(object sender, EventArgs e)
        {
            DBRoutines.Insert.Addcompany(TextUserName.Text, txtCo_JobPosition.Text, txtCo_JobPositionDescription.Text, txtCo_Email.Text, int.Parse(txtCo_Phone.Text), txtCo_Address.Text);



        }


        protected void Button3_Click(object sender, EventArgs e)
        {

        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            Panel1.Enabled = true;
            Panel1.Visible = true;
            Panel3.Enabled = false;
            Panel3.Visible = false;

        }
        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            Panel1.Enabled = false;
            Panel1.Visible = false;
            Panel3.Enabled = true;
            Panel3.Visible = true;


        }


        protected void DropDownListJobs_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }

}


My DBRoutines Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using System.Data;

namespace localhost_54355
{
    static class DBRoutines
    {
        public static class Insert
        {
            public static void Addcompany(string Employee_UserName, string Employee_Email, string Employee_Password, string Employee_Job, string Employee_FirstName, string Employee_LastName, string Employee_Location, int Employee_Phone, string Employee_CV, string Employee_Availability )
            {
                MySqlConnection con = new MySqlConnection("Database=jobfind;Data Source=localhost;User Id=root;Password=1234");

                MySqlCommand com = new MySqlCommand("Addcompany", con);
                com.CommandType = CommandType.StoredProcedure;

                com.Parameters.AddWithValue("aUserName", Employee_UserName);
                com.Parameters.AddWithValue("aEmployee_Email", Employee_Email);
                com.Parameters.AddWithValue("aEmployee_Password", Employee_Password);
                com.Parameters.AddWithValue("aEmployee_Job", Employee_Job);
                com.Parameters.AddWithValue("aEmployee_FirstName", Employee_FirstName);
                com.Parameters.AddWithValue("aEmployee_LastName", Employee_LastName);
                com.Parameters.AddWithValue("aEmployee_Location", Employee_Location);
                com.Parameters.AddWithValue("aEmployee_Phone", Employee_Phone);
                com.Parameters.AddWithValue("aEmployee_CV", Employee_CV);
                com.Parameters.AddWithValue("aEmployee_Availability", Employee_Availability);


                try
                {
                    con.Open();

                    com.ExecuteNonQuery();
                }
                catch (Exception Ex)
                {

                }
                finally
                {
                    con.Close();
                }
            }

}

}

属性名为Inherits。。将其添加到页面标签中

您是否也在aspx页面中添加了名称空间?只需添加到@EhsanSajjad的注释中,添加该名称空间的位置位于;它应该看起来像
Inherits=“localhost_54355.UI”
,带有我添加的名称空间:在我的Register.aspx页面中显示codebehind文件属性
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RegisterCustomer.aspx.cs" 
    MasterPageFile="~/Site.Master" Inherits="Hi_ImTheGreatNamespaceHere!" %>