0

我有一个包含两个更新面板的页面 - updatepanelform(可见),updatepanelthanks(隐藏)。我已经使用此方法在 asp 页面上的按钮单击事件上发送邮件。

protected void BtnRfqClick(object sender, EventArgs e)
{
    // Gmail Address from where you send the mail
    var fromAddress = TbEmailRfq.Text.ToString();
    // any address where the email will be sending
    var toAddress = "user@gmail.com";
    //Password of your gmail address
    var name = TbNameRfq.Text.ToString();
    const string fromPassword = "password";
    // Passing the values and make a email formate to display
    string subject = "Welcome To world";
    string body = "Name :" + TbNameRfq.Text.ToString() + Environment.NewLine +
                  "Email Id :" + TbEmailRfq.Text.ToString()
        + Environment.NewLine + TaComment.InnerText.ToString();
    // 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("user email", "password");
        smtp.Timeout = 20000;
    }
    // Passing values to smtp object
    smtp.Send(fromAddress, toAddress, subject, body);
}

一切正常,但在成功发送电子邮件后,我无法将 updatepanelform 的可见性设置为隐藏,并将 updatepanelthanks 设置为可见。

4

1 回答 1

0

发送电子邮件后放置以下内容:

updatepanelform.Visible = false;
updatepanelthanks.Visible = true;
于 2013-04-16T12:49:12.337 回答