I have a form on my page where users can send an email,
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");
The alert does not appear and the page simply redirects immediately, unless I comment out Response.Redirect, then the alert works. I want to display the alert and then redirect.
How can this be achieved? I thought of using a timer somehow, but I’m not sure if thats the best solution.
Thanks.
Let the JS do the redirect, instead of using Response.Redirect.
eg.