ASP.NET:插入'命名空间'后按钮不起作用

时间:2014-05-16 14:06:48

标签: c# mysql asp.net visual-studio-2012 visual-studio-2013

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();
                }
            }

}

}

嘿,我在使用MySQL数据库实现注册页面时遇到问题。当我插入'命名空间localhost_54355'在页面的代码中,我的按钮,文本框,面板无法识别。但是当我删除'命名空间'时,按钮变得可用,但我的类DBRoutines无法识别。你能帮我辨认一下这个问题吗?

谢谢!

注意: 这里的变量是' DBRoutines.Insert.Addcompany(TextUserName.Text,txtCo_JobPosition.Text,txtCo_JobPositionDescription.Text,txtCo_Email.Text,int.Parse(txtCo_Phone.Text),txtCo_Address.Text); '不正确。唯一正确的是' TextUserName.Text'但是当我删除“命名空间”时,它仍然只被识别出来。

1 个答案:

答案 0 :(得分:0)

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RegisterCustomer.aspx.cs" 
    MasterPageFile="~/Site.Master" Inherits="Hi_ImTheGreatNamespaceHere!" %>

属性名称为Inherits ..将其添加到页面标记