Automatic redirection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JoanneC

    #1

    Automatic redirection

    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="JavaS cript" runat="server">
    setTimeout("go_ now()",5000);
    function go_now () { window.location .href =
    "http://testweb.cs.ul.i e/PGrad/JoanneC/Input_Methods.a spx"; }
    </SCRIPT>

    end If

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

    Thanks
    Joanne
  • Craig Deelsnyder

    #2
    Re: Automatic redirection

    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.RegisterCl ientScriptBlock 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.RegisterSt artupScript in the server code instead, which causes this
    script to be written as-is, so 5 seconds after being written, the redirect
    would happen.

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET


    "JoanneC" <Joanne.Cheung@ ul.ie> wrote in message
    news:c3c239c6.0 308240617.4f655 e@posting.googl e.com...[color=blue]
    > 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="JavaS cript" runat="server">
    > setTimeout("go_ now()",5000);
    > function go_now () { window.location .href =
    > "http://testweb.cs.ul.i e/PGrad/JoanneC/Input_Methods.a spx"; }
    > </SCRIPT>
    >
    > end If
    >
    > Since when I used the response.redire ct method, it does not allow
    > delay before it redirect to the page.
    >
    > Thanks
    > Joanne[/color]


    Comment

    Working...