TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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
<
div
class
=
"contact-form wthree"
>
<
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
>
<
div
class
=
""
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtName"
placeholder
=
"Name"
>
</
asp:TextBox
>
</
div
>
<
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
>
<
div
class
=
""
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtSubject"
placeholder
=
"Subject"
>
</
asp:TextBox
>
</
div
>
<
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
>
<
div
class
=
""
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtEmail_ID"
placeholder
=
"Email Address"
>
</
asp:TextBox
>
</
div
>
<
br
/>
<
div
class
=
""
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtMessage"
TextMode
=
"MultiLine"
placeholder
=
"Message"
>
</
asp:TextBox
>
</
div
>
<
asp:Button
ID
=
"btnSubmit"
runat
=
"server"
Text
=
"Submit"
ValidationGroup
=
"contact"
onclick
=
"btnSubmit_Click"
/>
</
div
>
C#
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Net;
using
System.Net.Mail;
using
System.Text;
namespace
WhizCraft
{
public
partial
class
Contact_Us : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
btnSubmit_Click(
object
sender, EventArgs e)
{
Page.Validate();
if
(Page.IsValid)
{
MailMessage message =
new
MailMessage(
"
[email protected]
"
, txtEmail_ID.Text);
message.IsBodyHtml =
true
;
message.Body = txtMessage.Text +
"<br/> From:"
+ txtName.Text;
message.Subject = txtSubject.Text;
SmtpClient smtp =
new
SmtpClient(
"smtp.gmail.com"
, 587);
smtp.Credentials =
new
System.Net.NetworkCredential(
"
[email protected]
"
,
"akash#226187"
);
smtp.EnableSsl =
true
;
smtp.Send(message);
}
}
}
}
Reply
Answers (
9
)
implicit conversion from data type varchar to varbinary(max)
is there any solution pass default values and ajax values