Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling C# functions from a button onclick event
    primarykey
    data
    text
    <p>I am trying to call a function from a button onclick event but it is not executing the function. Below is the code:</p> <pre><code>&lt;script runat="server"&gt; 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"); } } &lt;/script&gt; &lt;asp:Button ID="RegistrationButton_Click" runat="server" CssClass="emsafrica-button" Text="Click to Create User Account" ValidationGroup="Login1" onclick="RegistrationButton_Click" TabIndex="7"/&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload