Open Multiple New Browser Windows from ASP.NET

Discussion in 'ASP .Net' started by dnes, Oct 2, 2006.

  1. dnes

    dnes Guest

    Open Multiple New Browser Windows from ASP.NET

    I'm having trouble figuring out how to open multiple new browser windows
    (each one displaying something different). As you can see from the code
    below, I have one ASP.NET page that has a foreach loop, and inside this
    foreach loop, I was to spawn a new browser window using the second ASP.NET
    page.

    This doesn't work. Only the last time through the foreach loop causes a new
    browser window to open. All other times through the loop don't open a new
    browser window.


    Would any one know how to make this work?



    Page1.aspx

    protected void LinkButtonGenerateMyGroup_Click(object sender, EventArgs e)
    {
    int i = 0;
    string from = ...;
    string to = ...;

    ...

    foreach (someobject in someobjects)
    {
    string sKey = "GenerateReport" + i.ToString();
    string sScript = System.String.Empty;

    i++;

    // Tried but doesn't work
    //sScript =
    "window.open('Page2.aspx?from=MyGroups&usedates=true&fromdate=" + from +
    "&todate=" + to + "', '" + sKey + "',
    'copyHistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollba
    rs=yes,status=no,toolbar=no');";
    //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), sKey,
    sScript, true);

    // Tried but doesn't work
    //sScript =
    "<script>window.open('Page2.aspx?from=MyGroups&usedates=true&fromdate=" +
    from + "&todate=" + to + "', '" + sKey + "',
    'copyHistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollba
    rs=yes,status=no,toolbar=no');</script>";
    //Response.Write(sScript);
    }
    }



    Page2.aspx

    protected void Page_Load(object sender, EventArgs e)
    {
    ...

    Response.Clear();
    Response.ClearContent();
    Response.ClearHeaders();
    Response.AppendHeader("content-length", result.Length.ToString());
    Response.ContentType = "Application/pdf";
    Response.BinaryWrite(result);
    Response.Flush();
    Response.Close();
    }
    dnes, Oct 2, 2006
    #1
    1. Advertising

  2. dnes

    dnes Guest

    Here's a little more info.

    Basically, I want the client-side JavaScript to execute, thereby opening the
    new browser with Page2.aspx. Then, I want Page2's load event to fire.
    Then, I want the next browser window to open and again fire Page2's load
    event. And so on and so forth until the foreach loop in Page1.aspx is
    complete.

    Any help would be greatly appreciated.
    Thanks!



    "dnes" <> wrote in message
    news:...
    > Open Multiple New Browser Windows from ASP.NET
    >
    > I'm having trouble figuring out how to open multiple new browser windows
    > (each one displaying something different). As you can see from the code
    > below, I have one ASP.NET page that has a foreach loop, and inside this
    > foreach loop, I was to spawn a new browser window using the second ASP.NET
    > page.
    >
    > This doesn't work. Only the last time through the foreach loop causes a

    new
    > browser window to open. All other times through the loop don't open a new
    > browser window.
    >
    >
    > Would any one know how to make this work?
    >
    >
    >
    > Page1.aspx
    >
    > protected void LinkButtonGenerateMyGroup_Click(object sender, EventArgs e)
    > {
    > int i = 0;
    > string from = ...;
    > string to = ...;
    >
    > ...
    >
    > foreach (someobject in someobjects)
    > {
    > string sKey = "GenerateReport" + i.ToString();
    > string sScript = System.String.Empty;
    >
    > i++;
    >
    > // Tried but doesn't work
    > //sScript =
    > "window.open('Page2.aspx?from=MyGroups&usedates=true&fromdate=" + from +
    > "&todate=" + to + "', '" + sKey + "',
    >

    'copyHistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollba
    > rs=yes,status=no,toolbar=no');";
    > //Page.ClientScript.RegisterClientScriptBlock(this.GetType(),

    sKey,
    > sScript, true);
    >
    > // Tried but doesn't work
    > //sScript =
    > "<script>window.open('Page2.aspx?from=MyGroups&usedates=true&fromdate=" +
    > from + "&todate=" + to + "', '" + sKey + "',
    >

    'copyHistory=no,directories=no,location=no,menubar=no,resizable=yes,scrollba
    > rs=yes,status=no,toolbar=no');</script>";
    > //Response.Write(sScript);
    > }
    > }
    >
    >
    >
    > Page2.aspx
    >
    > protected void Page_Load(object sender, EventArgs e)
    > {
    > ...
    >
    > Response.Clear();
    > Response.ClearContent();
    > Response.ClearHeaders();
    > Response.AppendHeader("content-length", result.Length.ToString());
    > Response.ContentType = "Application/pdf";
    > Response.BinaryWrite(result);
    > Response.Flush();
    > Response.Close();
    > }
    >
    >
    >
    dnes, Oct 2, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David
    Replies:
    5
    Views:
    7,003
    Daniel Walzenbach
    Dec 3, 2004
  2. TC
    Replies:
    3
    Views:
    3,286
  3. Ayoa

    Open multiple browser windows

    Ayoa, Sep 9, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    838
  4. Ayoa

    Open multiple browser windows

    Ayoa, Sep 12, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    419
  5. Geoff Fox
    Replies:
    8
    Views:
    135
    Dougeez
    Jul 7, 2006
Loading...

Share This Page