Button Click handler to Spawn Window

Discussion in 'ASP .Net Web Controls' started by Thom Little, Aug 22, 2004.

  1. Thom Little

    Thom Little Guest

    I am looking for a button click event handler that will open a new window
    and transfer control to it. This will be similar to target=_blank
    processing for a hyperlink control but using a button control in its place.

    What was the source of your information?

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --
     
    Thom Little, Aug 22, 2004
    #1
    1. Advertising

  2. Hey Thom,

    This is client-side stuff so, everything is built for you. How about
    something like this?

    Private Sub Page_Load _
    (ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MyBase.Load
    Button1.Attributes.Add _
    ("onclick", "var newwin = window.open" & _
    "('http://www.gc.ca/','_blank');newwin.focus();")
    End Sub

    Ken
    Microsoft MVP [ASP.NET]
    Toronto



    "Thom Little" <> wrote in message
    news:%23hq$...
    >I am looking for a button click event handler that will open a new window
    >and transfer control to it. This will be similar to target=_blank
    >processing for a hyperlink control but using a button control in its place.
    >
    > What was the source of your information?
    >
    > --
    > -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    > --
    >
    >
    >
     
    Ken Cox [Microsoft MVP], Aug 22, 2004
    #2
    1. Advertising

  3. Thom Little

    Thom Little Guest

    Excellent ... almost ...

    Your technique does spawn a new window and transfer control to it. The
    "_none" is unneeded. If not present it defaults to "_none". The
    "newwin.focus( )" is not needed since focus is set to the new window
    automatically.

    I can not find a way to have it load the new window into the same window as
    the caller (the "_self" option seems to have no affect and the request is
    seemingly ignored).

    Any ideas?

    (The reason I am doing this is that I have about 40 buttons on a page to
    call other existing pages. I would like to add an option of
    "spawn/no-spawn" to let the user select the mode they want to run.
    "no-spawn" would use the existing window. "spawn" would create a new window
    and use it.)

    --
    -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    --

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:%...
    > Hey Thom,
    >
    > This is client-side stuff so, everything is built for you. How about
    > something like this?
    >
    > Private Sub Page_Load _
    > (ByVal sender As System.Object, _
    > ByVal e As System.EventArgs) _
    > Handles MyBase.Load
    > Button1.Attributes.Add _
    > ("onclick", "var newwin = window.open" & _
    > "('http://www.gc.ca/','_blank');newwin.focus();")
    > End Sub
    >
    > Ken
    > Microsoft MVP [ASP.NET]
    > Toronto
    >
    >
    >
    > "Thom Little" <> wrote in message
    > news:%23hq$...
    >>I am looking for a button click event handler that will open a new window
    >>and transfer control to it. This will be similar to target=_blank
    >>processing for a hyperlink control but using a button control in its
    >>place.
    >>
    >> What was the source of your information?
    >>
    >> --
    >> -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
    >> --
    >>
    >>
    >>

    >
     
    Thom Little, Aug 23, 2004
    #3
    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. Purvi T
    Replies:
    0
    Views:
    881
    Purvi T
    Oct 19, 2004
  2. Amy
    Replies:
    0
    Views:
    1,011
  3. Derek Basch
    Replies:
    2
    Views:
    1,314
    Donn Cave
    Jan 21, 2005
  4. Ed Hames
    Replies:
    0
    Views:
    388
    Ed Hames
    Apr 16, 2008
  5. Edgardo Hames
    Replies:
    1
    Views:
    366
    Ed Hames
    May 6, 2008
Loading...

Share This Page