views:

81

answers:

1

I am using Thread.sleep(5000) and then using Page.ClientScript.RegisterClientScriptBlock(type, key, script) function to open a new window. I am getting 5 new windows but not in each 5 sec, they all appear together, after 25 sec. Here is my sample code:

for(int i=0;i<5;i++)
{
    System.Threading.Thread.Sleep(5000);
    string openPage = "<script type='text/javascript' language='javascript'>";
    openPage += "window.open('http://www.winpossible.com','mywindow" + i + "','width=600,height=800,toolbar=no,location=Yes,directories=no,status=no,resizable=yes');";                       openPage += "</script>";

    // Open a new window if there is a new teacher-Student pair comes.
    Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "sample" + i, openPage);
}

Thanks in advance for your insightful and elegant solutions to this problem! ;o)

+1  A: 

As your using server-side code, it runs on the server, and all the delays goes before you send the HTML page to the client.

When the HTML page gets to the client, it shows the 5 pages at once.

What you must do is open the pages using javascript.

Look at this example:

http://javascript.internet.com/navigation/delayed-popup.html

It opens a new window after a delay, you can use the same concept for opening your five windows.

Doing that from server side code is not possible.

tekBlues