-2

I want to load page2.aspx 10 seconds after page1.aspx loads. This is my code. All help appreciated.

namespace test
{   
public partial class page1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Server.Transfer("page2.aspx");
    }
}
}

I want page1 to show for 10 seconds and then load page 2. I cannot use thread.sleep because it does not load the page at all.

Nick
  • 63
  • 11
  • Add a `Thread.Sleep()` before the transfer. But, that will not load page1 at all, it'll just wait for some time and go to page 2. – Arghya C Jan 22 '16 at 07:59
  • 4
    Possible duplicate of [How do I get my C# program to sleep for 50 msec?](http://stackoverflow.com/questions/91108/how-do-i-get-my-c-sharp-program-to-sleep-for-50-msec) – Plamen G Jan 22 '16 at 08:02
  • 1
    I cannot use thread.sleep because it does not load the page at all. – Nick Jan 22 '16 at 08:13
  • Another simple way would to add timer and intialize and start timer on page prerender event and handle timer elapsed event and do server.transfer – Viru Jan 22 '16 at 08:15
  • It'd be interesting to know what exactly you are trying to achieve. Show a page for few seconds, then suddenly load another page! Depending on what you need, it might be just a popup, or client side redirect or something else. – Arghya C Jan 22 '16 at 08:17
  • nobody didn't cancelled *meta refresh* tag. Add next code to your head tag: – Khazratbek Jan 22 '16 at 08:35
  • @Viru how exactly can I do it.? Can you please help.? – Nick Jan 22 '16 at 09:37

1 Answers1

1

Nobody cancelled refresh meta tag. Add following to your head:

<meta http-equiv="refresh" content="10;URL=Page2.aspx" />

Posted my comment as answer

Khazratbek
  • 1,656
  • 2
  • 10
  • 17
  • 1
    It would refresh the page. I dont want to do that. – Nick Jan 22 '16 at 09:36
  • @nick It will send you to Page2.aspx 10 seconds later. Just try this, and you will see, that this is correct. – Khazratbek Jan 22 '16 at 13:13
  • @Nick but it is your choice. It's a simple code that will give you what you need. If you will use timers, so on, you have to do many steps instead of such a simple solution. – Khazratbek Jan 22 '16 at 13:14