我试图从按钮 onclick 事件中调用一个函数,但它没有执行该函数。下面是代码:
<script runat="server">
protected void RegistrationButton_Click(object sender, EventArgs e)
{
TextBox un = Post0.FindControl("aspxTextBox_UserName") as TextBox;
TextBox pwd = Post0.FindControl("aspxTextBox_Password") as TextBox;
TextBox cpwd = Post0.FindControl("aspxTextBox_ConfirmPassword") as TextBox;
TextBox txtE = Post0.FindControl("aspxTextBox_Email") as TextBox;
TextBox SQ = Post0.FindControl("aspxTextBox_SecurityQ") as TextBox;
TextBox SA = Post0.FindControl("aspxTextBox_SecurityA") as TextBox;
if (pwd == cpwd)
{
System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection("ConString_Online_EMS_AFRICA_db");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "INSERT INTO EMSPWD (Username, Password, Email, SecurityQ, SecurityA) VALUES (" + un + ", " + pwd + ", " + txtE + ", " + SQ + ", " + SA + " )";
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
cmd.ExecuteNonQuery();
sqlConnection1.Close();
Response.Redirect("02_Registration.aspx");
}
else
{
Console.WriteLine("Passwords don't Match");
}
}
</script>
<asp:Button ID="RegistrationButton_Click" runat="server" CssClass="emsafrica-button" Text="Click to Create User Account" ValidationGroup="Login1" onclick="RegistrationButton_Click" TabIndex="7"/>