Open new window in codebehind and add the window handle to javascript array

Discussion in 'ASP .Net' started by RJN, Oct 10, 2004.

  1. RJN

    RJN Guest

    Hi

    In the mainscreen I have a datagrid and from here I open new windows on
    click of link button. And I'm doing it through RegisterStartupScript

    Me.RegisterStartupScript("PopUp", _
    "<script language='JavaScript'> " & _
    "var winOp = window.open('MyScreen.aspx', 'test');" + _
    "if (winOp != null) winOp.focus();" + _
    "</script>")

    I want to keep track of the windows that are opened and add the window
    handles to a javascript array whenever a new window is opened in the
    codebehind. In the .aspx page I should be able to access this array.

    var winArray = new Array;// populated in .aspx.vb
    function test()
    {
    for(i=0;i<winArray.length;++i)
    alert(winArray.name);
    }

    Is there a way to do this?Can this be done through
    Page.RegisterArrayDeclaration?


    Thanks

    rjn



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    RJN, Oct 10, 2004
    #1
    1. Advertising

  2. Since the window isn't opened until the response is renedered on the client,
    you can't get hold of that handle on the server side.

    Add JavaScript code to add the window handle to the array on the client side
    when the window is opened instead.

    --
    Patrik Löwendahl [C# MVP]
    www.cshrp.net - "Elegant code by witty programmers"

    "RJN" <> wrote in message
    news:%...
    > Hi
    >
    > In the mainscreen I have a datagrid and from here I open new windows on
    > click of link button. And I'm doing it through RegisterStartupScript
    >
    > Me.RegisterStartupScript("PopUp", _
    > "<script language='JavaScript'> " & _
    > "var winOp = window.open('MyScreen.aspx', 'test');" + _
    > "if (winOp != null) winOp.focus();" + _
    > "</script>")
    >
    > I want to keep track of the windows that are opened and add the window
    > handles to a javascript array whenever a new window is opened in the
    > codebehind. In the .aspx page I should be able to access this array.
    >
    > var winArray = new Array;// populated in .aspx.vb
    > function test()
    > {
    > for(i=0;i<winArray.length;++i)
    > alert(winArray.name);
    > }
    >
    > Is there a way to do this?Can this be done through
    > Page.RegisterArrayDeclaration?
    >
    >
    > Thanks
    >
    > rjn
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Patrik Löwendahl [C# MVP], Oct 10, 2004
    #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. Gordon
    Replies:
    3
    Views:
    311
    Steven Burn
    Apr 16, 2004
  2. PC HUA
    Replies:
    2
    Views:
    423
    PC HUA
    May 19, 2004
  3. IveCal
    Replies:
    0
    Views:
    176
    IveCal
    Apr 2, 2007
  4. Replies:
    1
    Views:
    241
  5. Replies:
    2
    Views:
    470
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page