.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> .NET Framework >> Post New QuestionBookmark and Share Subscribe to Forum

C# functions

Posted By: gmboat     Posted Date: June 06, 2013    Points:5   Category :.NET Framework
Hi. I am trying to create a function that is called by an onclick event but it is not executing the function. Below is some code:

<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;

//string Username = aspxTextBox_UserName.Text;
//string Password = aspxTextBox_Password.Text;
//string ConfirmPassword = aspxTextBox_ConfirmPassword.Text;
//string Email = aspxTextBox_Email.Text;
//string SecurityQ = aspxTextBox_SecurityQ.Text;
//string SecurityA = aspxTextBox_SecurityA.Text;

//Console.WriteLine(un);

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"/>

Can anyone help?



Responses
Author: Amit Mehra             
Posted Date: June 06, 2013     Points: 20   

Set/add AutoEventWireup="true" on your page directive..

eg

<% @Page AutoEventWireup="true" %>

This might help you


Thanks,
Amit
Please "Mark As Answer " if this post help you.


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend