Button3.PerformClick()

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hello,
I am trying to program a button to click with code. I
do not want to have to repeat the code that I already have
in the project. I figured that I could use the button
that is alreay there instead of redoing it. The only
thing is that I can't seem to get the button to fire
without the user clicking it. It says proform click is
not a member of sysyem.web.ui.webcontrols.button. Is
there a way to make this happen on a webform

example code:
Private Sub Button4_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button4.Click
txtReqAsset.Text = txtLinked1.Text
Button3.PerformClick()
End Sub
 
Hi Brian,

When I understand you right, I am not sure of that, than do
you want in the serverside event of the button 4 also perform button 3.

There are 2 simple approaches for that:

Private Sub Button4_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button4.Click

DoTheThingsForButton3(sender,e)

End sub

Private Sub Button3_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button4.Click

DoTheThingsForButton3(sender,3)

End sub

Private DoTheThingsForButton3()
Do what you want.
End sub

A simple approach when you do not need the sender and the e(event) you can
do in the Button4 event

Button3_Click(nothing,nothing)

I hope this was what you did mean and that it did help?

Cor
 
Hello Brian,

Like all things. The button must have an event handler. When you create an
event your create a function ( perform_click ) and add a hanler which binds
the event to the function. This is where you are going wrong. You cant
simply add a button and expect something to happen unless you make it so.

If I understand you correctly, you want the button to invoke code used by
another one right ?. If this is the case add an event handler for the new
button and point it to the function

OHM
 
* "Brian said:
I am trying to program a button to click with code. I
do not want to have to repeat the code that I already have
in the project. I figured that I could use the button
that is alreay there instead of redoing it. The only
thing is that I can't seem to get the button to fire
without the user clicking it. It says proform click is
not a member of sysyem.web.ui.webcontrols.button. Is
there a way to make this happen on a webform

'PerformClick' is supported by the Windows Forms button control. You
may want to remove the code from the handler, add it to a separate
procedure and call this procedure from the 'Click' event handler. This
procedure can be called from other code too.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Herfried,
'PerformClick' is supported by the Windows Forms button control. You
may want to remove the code from the handler, add it to a separate
procedure and call this procedure from the 'Click' event handler. This
procedure can be called from other code too.

Don't make an excuus, I think Brian sees that himself also.

:-)

Cor
 
Back
Top