2 weixin 35799245 weixin_35799245 于 2016.09.26 14:23 提问

asp.net程序中 单击buttn按钮没有响应其后台的单击事件

前台:

 <form id="form1" runat="server" action="./Demo2.aspx">
        <div>
            <table style="height: 326px; width: 935px">
                <tr>
                    <td class="auto-style3">キーワード検索:
                        <asp:TextBox ID="SelectText" runat="server" Width="428px" Height="16px" Text="社員氏名をローマ字または漢字で検索してください"></asp:TextBox>
                        &nbsp;
                        <asp:Button ID="SelectBtn" runat="server" Text="検索" Width="103px" OnClick="SelectBtn_Click" />
 后台:
    protected void SelectBtn_Click(object sender, EventArgs e)
        {
            string sqlCon = "Data Source=tcp:m7pevx6s1h.database.windows.net;Initial Catalog=srpnotesdev02;User ID=o365wp@m7pevx6s1h;Password=P@ssw0rd!;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";
            SqlConnection scon = new SqlConnection(sqlCon);
            if (scon.State != ConnectionState.Open)
            {
                scon.Open();
            }
            string sql;

            string text = this.SelectText.Text.ToString();
            string parm = @"[/^[a-zA-Z]+$/]";
            Regex rg = new Regex(parm);
            Match mh = rg.Match(text);
            if (mh.Success)
            {
                sql = " select EName,UniqueNo,jno,name,GroupSName_1,GroupSName_2,GroupSName_3,O365_Email from MainForm where EName='" + this.SelectText.Text.ToString() + "'  ";


            }
            else
            {
                sql = " select EName,UniqueNo,jno,name,GroupSName_1,GroupSName_2,GroupSName_3,O365_Email from MainForm where name='" + this.SelectText.Text.ToString() + "'  ";


            }
            SqlCommand scmd = new SqlCommand(sql, scon);
            SqlDataAdapter sda = new SqlDataAdapter(scmd);
            DataTable dt = new DataTable();
            sda.Fill(dt);
            Console.WriteLine(dt);
            Rept.DataSource = dt;
            Rept.DataBind();
        }



    }
}

1个回答

weixin_35799245
weixin_35799245   2016.09.26 14:24
已采纳
                                            这个是前台
 <form id="form1" runat="server" action="./Demo2.aspx">
        <div>
            <table style="height: 326px; width: 935px">
                <tr>
                    <td class="auto-style3">キーワード検索:
                        <asp:TextBox ID="SelectText" runat="server" Width="428px" Height="16px" Text="社員氏名をローマ字または漢字で検索してください"></asp:TextBox>
                        &nbsp;
                        <asp:Button ID="SelectBtn" runat="server" Text="検索" Width="103px" OnClick="SelectBtn_Click" />

Csdn user default icon
上传中...
上传图片
插入图片