click button

G

Guest

In a web form, I want the user clicks on one button and this button will
trigger another button/link which will open a new browser window? How to do
that? Is there any method like
Button.performclick?

Thanks
 
S

Scott M.

Opening another browser window is not something you can do from server-side
code. Only the client can control the client. You have 2 questions here so
let me answer them individually.

1. How to call the click event of a button from the click event of another
button: This is accomplished by simply placing a call to the click event
handler of the second button in the first:

Sub Button1_Click() Handles Button1.Click
'Call the click event handler of button2
Button2_Click()
End Sub

Sub Button2_Click() Handles Button2.Click
'Button2's click event code here
End Sub

2. How to open a new browser window. As stated, only client-side code
(JavaScript) can do this, so you either have to embed a client-side script
and add a client-side event handler to a button
(onClick="window.open('fileToOpen')) or send this code to the client-side
control from the server side:

Page_Load()
Button2.Attributes.Add("onClick","window.open('fileToOpen')")
End Sub
 
G

Guest

Thanks.
But the problem is that... I want to ensure that some server scripts will
run before another browser window opens... For the
button.attribute.add("onclick", "javascript:window.open")... It seems that it
cannot gurantee this ...
 
S

Scott M.

How about having one .aspx page run your server code and when they are done,
simply use response.redirect or server.transfer to call another server page
that includes the button with the onClick event handler?
 
G

Guest

Thanks.

Scott M. said:
How about having one .aspx page run your server code and when they are done,
simply use response.redirect or server.transfer to call another server page
that includes the button with the onClick event handler?
 

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

Top