Inside an event in my code behind file I want to run a script that redirect the user to a specific page after 3 seconds. I understand that I can use the Page.ClientScript line below with a setTimeout, but what I need help with is what to actually put inside the setTimeout statement to get this works?
At the bottom is the code line I use for redirecting, that I want to replace with the Page.ClientScript line.
Thanks in advance!
Page.ClientScript.RegisterStartupScript(this.GetType(), "redirect", "setTimeout('???', 3000);", true);
Response.Redirect(String.Format("~/Edit.aspx?id={0}", movie.MovieID), false);
NOTE: I have tried the following without any luck:
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "setTimeout('top.location.href = " + String.Format("~/Edit.aspx?id={0}", movie.MovieID) + "', 3000);", true);
Replace TARGET with the URL you want to redirect to.
You can build the target URL dynamically from the codebehind: