我的页面上有一个表单,用户可以在其中发送电子邮件,
try
{
smtpClient.Send(message);
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Key",
"alert('Thank you for your submission.');", true);
}
catch(Exception)
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Key",
"alert('There was an error processing your request.');", true);
}
Response.Redirect("home.aspx");
警报不会出现,页面只是立即重定向,除非我注释掉 Response.Redirect,否则警报会起作用。我想显示警报然后重定向。
如何做到这一点?我想以某种方式使用计时器,但我不确定这是否是最好的解决方案。
谢谢。