Button Click

ThomasM

Member
Joined
Apr 5, 2006
Messages
17
Programming Experience
Beginner
Is it possible to force a button click for another button within a button?

example

Protected Sub btnPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrint.Click
'Perfom something
'Force a seperate button click on the same page

End Sub


Many Thanks
 
why dont you make separate subroutine in second button click event and call it from first like:

VB.NET:
Expand Collapse Copy
[SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Sub[/COLOR][/SIZE][SIZE=2] btnSomething_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles [/COLOR][/SIZE][SIZE=2]btnSomething[/SIZE][SIZE=2].Click
MySub()[/SIZE][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Sub

[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Sub[/COLOR][/SIZE][SIZE=2] btnPrint_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btnPrint.Click
'Perfom something
MySub()[/SIZE][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Sub[/COLOR][/SIZE]
 
or to run the code in another button's click event simply call the other button's .PerformClick() method

VB.NET:
Expand Collapse Copy
[SIZE=2][COLOR=#0000ff]Protected [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] btnPrint_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] btnPrint.Click
  'Perfom something
  OtherButton.PerformClick()[/SIZE][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]
 
These fucntions would work in most cases but since I wasnt very clear on my first post, the replys wont work in my situation.

Here is what I have...

I have a WebForm that includes a table with empty fields. I am looking to
print this "Credit Application" but I want to do it when the Form Loads.

I found a control on the web that will print the page the way I want it to.
What I am not sure on how to do is call that control when the page loads.

I have included the "Control" button on the page but again rahter than making the user click the button I want to force the call to the control when the page loads. I thought I could perform a "Button Click" for that control but that doesnt work.

I am not certain if I am going about this the wrong way... So if anyone has any other suggetions on how I can this the page to print on Form Load I would greatly appricate it.

Many Thanks !!!!
 
Back
Top