Akash Patel

Akash Patel

  • NA
  • 117
  • 40.2k

Button click event not firing up

Nov 29 2018 1:09 AM
I have a contact from in which i have to send email. But when all the details is filled and the button is clicked. the click event code is not executing. i set breakpoint on both button click event and page load event. the debugger passes through page load event of content and master page. But the button click event is not firing. Also no code is written in page load event. Below is the code both ASP and C#
 
ASP
  1. <div class="contact-form wthree">  
  2. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Font-Bold="true" ValidationGroup="contact" ErrorMessage="Name Required" ControlToValidate="txtName" SetFocusOnError="true" Font-Size="Small" ForeColor="Red"></asp:RequiredFieldValidator>  
  3. <div class="">  
  4. <asp:TextBox runat="server" ID="txtName" placeholder="Name"></asp:TextBox>  
  5. </div>  
  6. <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Font-Bold="true" ValidationGroup="contact" ErrorMessage="Subject Required" ControlToValidate="txtSubject" SetFocusOnError="true" Font-Size="Small" ForeColor="Red"></asp:RequiredFieldValidator>  
  7. <div class="">  
  8. <asp:TextBox runat="server" ID="txtSubject" placeholder="Subject"></asp:TextBox>  
  9. </div>  
  10. <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Font-Bold="true" ValidationGroup="contact" ErrorMessage="Email Address Required" ControlToValidate="txtEmail_ID" SetFocusOnError="true" Font-Size="Small" ForeColor="Red"></asp:RequiredFieldValidator>  
  11. <div class="">  
  12. <asp:TextBox runat="server" ID="txtEmail_ID" placeholder="Email Address"></asp:TextBox>  
  13. </div>  
  14. <br />  
  15. <div class="">  
  16. <asp:TextBox runat="server" ID="txtMessage" TextMode="MultiLine" placeholder="Message"></asp:TextBox>  
  17. </div>  
  18. <asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="contact" onclick="btnSubmit_Click" />  
  19. </div>  
C#
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using System.Net;  
  8. using System.Net.Mail;  
  9. using System.Text;  
  10. namespace WhizCraft  
  11. {  
  12. public partial class Contact_Us : System.Web.UI.Page  
  13. {  
  14. protected void Page_Load(object sender, EventArgs e)  
  15. {  
  16. }  
  17. protected void btnSubmit_Click(object sender, EventArgs e)  
  18. {  
  19. Page.Validate();  
  20. if (Page.IsValid)  
  21. {  
  22. MailMessage message = new MailMessage("[email protected]", txtEmail_ID.Text);  
  23. message.IsBodyHtml = true;  
  24. message.Body = txtMessage.Text + "<br/> From:" + txtName.Text;  
  25. message.Subject = txtSubject.Text;  
  26. SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);  
  27. smtp.Credentials = new System.Net.NetworkCredential("[email protected]""akash#226187");  
  28. smtp.EnableSsl = true;  
  29. smtp.Send(message);  
  30. }  
  31. }  
  32. }  
  33. }  

Answers (9)