我有这个简单的表单,我正在测试VS2012和vb.net中构建的。代码发送两次电子邮件,我确实放了断点,我不知道它为什么循环两次。
代码:
Protected Sub btnSubmit_OnClick(sender As Object, e As EventArgs) Handles btnSubmit.Click
Dim formBody As String
formBody = "<b>Donation Amount: <b/>" + txtAmount.Text.Trim()
Dim mailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
mailMessage.From = New System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings("fromEmailAddress"))
mailMessage.To.Add(New System.Net.Mail.MailAddress("webmaster@example.com"))
mailMessage.IsBodyHtml = True
mailMessage.Subject = "Donation Form"
mailMessage.Body = formBody
Dim smtpClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
smtpClient.Send(mailMessage)
Response.Redirect("MemDonation_Confirmation.aspx", False)
End Sub
这是表格:
<asp:Label runat="server" ID="lblAmount" Text="Donation Amount: "></Label>
<asp:TextBox ID="txtAmount" runat="server"></asp:TextBox>
<asp:Button runat="server" ID="btnSubmit" OnClick="btnSubmit_OnClick" Text="Submit" style="height: 26px" />
Call Stack看起来像这样,我不知道该怎么做:
Step into: Stepping over non-user code 'MemDonation.txtAmount.get'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.MailMessage'
Step into: Stepping over non-user code 'System.Configuration.ConfigurationManager.AppSettings.get'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.To.get'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.IsBodyHtml.set'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.Subject.set'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.Body.set'
Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.SmtpClient'
Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.Send'
Step into: Stepping over non-user code 'System.Web.UI.Page.Response.get'
Step into: Stepping over non-user code 'MemDonation.txtAmount.get'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.MailMessage'
Step into: Stepping over non-user code 'System.Configuration.ConfigurationManager.AppSettings.get'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.To.get'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.IsBodyHtml.set'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.Subject.set'
Step into: Stepping over non-user code 'System.Net.Mail.MailMessage.Body.set'
Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.SmtpClient'
Step into: Stepping over non-user code 'System.Net.Mail.SmtpClient.Send'
Step into: Stepping over non-user code 'System.Web.UI.Page.Response.get'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.Button.OnClick'
Step into: Stepping over non-user code 'System.Web.UI.WebControls.Button.RaisePostBackEvent'
Step into: Stepping over non-user code 'System.Web.UI.Page.ProcessRequestMain'
Step into: Stepping over non-user code 'ASP.memdonation_aspx.GetTypeHashCode'
Step into: Stepping over non-user code 'System.Web.UI.Page.SaveAllState'
Step into: Stepping over non-user code 'System.Web.UI.Page.ProcessRequestMain'
Step into: Stepping over non-user code 'System.Web.UI.Page.ProcessRequest'
Step into: Stepping over non-user code 'System.Web.UI.Page.ProcessRequest'
Step into: Stepping over non-user code 'ASP.memdonation_aspx.ProcessRequest'
Step into: Stepping over non-user code 'System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute'
Step into: Stepping over non-user code 'System.Web.HttpApplication.ExecuteStep'
答案 0 :(得分:0)
您可能会为btnSubmit.Click
注册多个事件处理程序。函数中的Handles
子句将自动为您创建一个子句。检查通过addhandler
动态添加的其他处理程序。