Automatic redirection

  • Thread starter Thread starter JoanneC
  • Start date Start date
J

JoanneC

How can I incorporate the following javascript code in an ASP.NET
application (using VB.NET)
Like the following

If textbox1.text = "" then

<SCRIPT LANGUAGE="JavaScript" runat="server">
setTimeout("go_now()",5000);
function go_now () { window.location.href =
"http://testweb.cs.ul.ie/PGrad/JoanneC/Input_Methods.aspx"; }
</SCRIPT>

end If

Since when I used the response.redirect method, it does not allow
delay before it redirect to the page.

Thanks
Joanne
 
Well, you could use a Thread.Sleep on the server side to wait for 5 seconds
then goto the next page...may not be what was intended.

Otherwise, you could use Page.RegisterClientScriptBlock to put your script
in the page (but put it in a function call) and redirect via JScript when
your click event or redirection event is initiated by the user.

Or, after postback have the page redisplay itself but use
Page.RegisterStartupScript in the server code instead, which causes this
script to be written as-is, so 5 seconds after being written, the redirect
would happen.
 
Back
Top