提交时清除文本框
本文关键字:文本 清除 提交 | 更新日期: 2023-09-27 18:24:45
嗨,我希望在用户单击按钮时清除文本框。然而,我的代码不起作用。这是我的密码。
System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
m.Body = name.Text + Environment.NewLine + phone.Text + Environment.NewLine + email.Text + Environment.NewLine + message.Text;
m.IsBodyHtml = false;
m.To.Add("support@");
m.From = new System.Net.Mail.MailAddress(email.Text);
m.Subject = "Contact us form submisson";
m.Headers.Add("Reply-To", "your email account");
System.Net.Mail.SmtpClient s = new System.Net.Mail.SmtpClient();
s.UseDefaultCredentials = false;
s.Credentials = c;
s.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
s.EnableSsl = true;
s.Port = 587;
s.Host = "smtp.gmail.com";
s.Send(m);
lblCorrectCode.Text = "Contact Form Has been submited we will be in touch shortly";
name.Text = string.Empty;
phone.Text = string.Empty;
email.Text = string.Empty;
message.Text = string.Empty;
我非常希望你不要在页面加载中填充它,也不要检查isPostBack
try
{
s.Send(m);
}
finally
{
lblCorrectCode.Text = "Contact Form Has been submited we will be in touch shortly";
name.Text = string.Empty;
phone.Text = string.Empty;
email.Text = string.Empty;
message.Text = string.Empty;
}