Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:32:38+00:00 2026-05-31T07:32:38+00:00

Inside an event in my code behind file I want to run a script

  • 0

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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:32:39+00:00Added an answer on May 31, 2026 at 7:32 am
    setTimeout("top.location.href = 'TARGET'", 3000);
    

    Replace TARGET with the URL you want to redirect to.

    You can build the target URL dynamically from the codebehind:

    string targetUrl = String.Format("/Edit.aspx?id={0}", movie.MovieID);
    string javaScript = "setTimeout(\"top.location.href = '" + targetUrl + "'\", 3000);";
    
    ClientScript.RegisterStartupScript(typeof(Page), "redirect", javaScript, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen this done inside of an event handler directly behind the .xaml file
I have inside repeater when i tried to find above placeholder in code behind
I have aspx page where there is no code behind. Server side Code written
I have a linkbutton in gridview and i want to click event on code
Does anybody know the trick, how to free control inside its event handler ?
I have a question similar to the one here: Event handlers inside a Javascript
Why would a button inside a Repeater not fire the Repeater's ItemCommand event? Is
i have a click event for $('#blah div'). div has text inside of it
I try to do a custom CanExecuteChanged event for a command button. Inside CanExecuteChanged
I was wondering how, from an event on the child object inside a templatefield

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.