Click here to Skip to main content
15,894,312 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Button Click Event Stop working for all the button in my website after i add bootstrap theme that i picked from w3 school
here is button code

<asp:Button ID="Button2" runat="server" style="color: #CC66FF" 
                Text="Save Ven Info" Width="91px" onclick="Button2_Click" />


and here its CS file code

C#
protected void Button2_Click(object sender, EventArgs e)
   {
       try
       {
           SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Supply Chain ManagementConnectionString3"].ConnectionString);
           conn.Open();
           string insertQuery = "insert into VendorInfo(Name,Address,Email,Phoneno,Faxno) values(@Name,@Address,@Email,@Phoneno,@Faxno)";
           SqlCommand Command = new SqlCommand(insertQuery, conn);

           Command.Parameters.AddWithValue("@Name", TextBox6.Text);
           Command.Parameters.AddWithValue("@Address", TextBox7.Text);
           Command.Parameters.AddWithValue("@Email", TextBox8.Text);
           Command.Parameters.AddWithValue("@Phoneno", TextBox9.Text);
           Command.Parameters.AddWithValue("@Faxno", TextBox10.Text);

           Command.ExecuteNonQuery();
           //Response.Redirect("Manage Employees.aspx");
           Response.Write("Saved");
           conn.Close();
       }
       catch (Exception ex)
       {
           Response.Write("Data Corrupt" + ex.Message);
       }
   }
Posted
Comments
Sergey Alexandrovich Kryukov 3-Feb-16 16:21pm    
"Not working" is not informative. Did you use the debugger?
Also, it's really bad to handle exceptions locally. Do you handle exceptions in almost all functions of event handlers?
—SA
Member 12245428 3-Feb-16 16:33pm    
NOt use debugging yet just saving and then built solution then page test in browser and yes i use exception method when adding data to my database
Member 12245428 3-Feb-16 16:34pm    
Used Debugger but still button click event not working
Arasappan 4-Feb-16 0:24am    
use break point
koolprasad2003 4-Feb-16 0:53am    
simple delete current event and re-create it by double click on button

I am not sure if it is copy/paste or you have written code here. I see one issue with button declaration. The onclick event should be OnClick (o and c capital). Can you check if it is working
 
Share this answer
 
Delete onclick="Button2_Click" from aspx page .. and Re-create Button Event on Double click on the button from design view .
and also check if any other control or element are overlap to Button2 like div etc.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900