c# - ASP.NET:插入后按钮不起作用 'namespace'

标签 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 数据库实现注册页面时遇到问题。当我在页面代码中插入“namespace 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”,但它仍然只有在我删除“命名空间”时才能被识别。

最佳答案

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

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

关于c# - ASP.NET:插入后按钮不起作用 'namespace',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23697303/

相关文章:

PHP/MySQL 事件(ala facebook)

mysql - Erlang 无法连接到 mysql/mariadb

asp.net - global.asax Application_Error 未触发

c# - 使用以纬度/经度开头的 Linq Sql 查询

mysql - 使用从另一个表新插入的 id 更新一个表

c# - Ascii 范围考虑二进制文件?

c# - 如何使用多线程为集合中的每个项目调用存储过程

asp.net - 中继器中的下拉列表,选定的索引更改后不起作用

c# - 整合银行账户

c# - SerialData.Eof情况