我有我的Index.aspx页上的一个简单的形式,它发送电子邮件按钮点击代码隐藏文件OnClick事件不触发任何浏览器
<form runat="server" action="index.aspx">
<label>Name</label>
<input type="text" runat="server" class="form-control" placeholder="Name" id="name" required data- validation-required-message="Please enter your name.">
<label>Email Address</label>
<input type="email" runat="server" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address.">
<label>Phone Number</label>
<input type="tel" runat="server" class="form-control" placeholder="Phone Number" id="phone" required data-validation-required-message="Please enter your phone number.">
<label>Message</label>
<textarea rows="5" runat="server" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."></textarea>
<asp:Button runat="server" Text="Send" OnClick="Button1_Click" CssClass="btn btn-success btn-lg"></asp:Button>
</form>
Button1_Click事件上的任何browser.On不烧我的代码背后我有以下代码
protected void Button1_Click(object sender, EventArgs e)
{
try
{
// Gmail Address from where you send the mail
var fromAddress = Request.Form["email"];
// any address where the email will be sending
var toAddress = "[email protected]";
//Password of your gmail address
const string fromPassword = "abc";
// Passing the values and make a email formate to display
string subject = "Feedback of COMIC MAKER";
string body = "From: " + Request.Form["name"] + "\n";
body += "Subject: " + Request.Form["message"] + "\n";
body += "Question: \n" + Request.Form["phone"] + "\n";
// smtp settings
var smtp = new System.Net.Mail.SmtpClient();
{
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 20000;
}
// Passing values to smtp object
smtp.Send(fromAddress, toAddress, subject, body);
}
catch { }
}
什么都没发生,我已经把断点,但没有发生。需要帮助吗?
试着给你的,但吨一个id ... http://stackoverflow.com/questions/3445515/input-type-button-runat-server-wont-work-in-asp-net – 2014-11-02 14:08:35
我已经给了身份证,但仍然没有执行代码 – 2014-11-02 14:12:16
你阅读链接?它还说要添加:UseSubmitBehavior =“False”... – 2014-11-02 14:15:27