“邮件发送成功”后更新面板可见性隐藏

时间:2013-04-16 12:41:08

标签: c# asp.net ajax gmail

我有一个包含两个更新面板的页面 - 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的可见性设置为hidden和updatepanelthanks可见。

1 个答案:

答案 0 :(得分:0)

发送电子邮件后发出以下信息:

updatepanelform.Visible = false;
updatepanelthanks.Visible = true;