Automatic redirection

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
 
C

Craig Deelsnyder

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top