Button Click handler to Spawn Window

T

Thom Little

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?
 
K

Ken Cox [Microsoft MVP]

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
 
T

Thom Little

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 said:
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 said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top