Button.Click fired twice

ganders

Freshman
Joined
Nov 25, 2004
Messages
32
hi folks

the following code creates a compositecontrol and adds a button to the control. the button gets a handler for the click-event.

this works all fine, except: the sub button_click is called twice.

why???

best regards

george

Visual Basic:
Private WithEvents btnSearch As New WebControls.Button
Protected Overrides Sub CreateChildControls()
  AddHandler btnSearch.Click, AddressOf btnSearch_Click
  Me.Controls.Add(btnSearch)
  MyBase.CreateChildControls()
End Sub
Public Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
  ' this code is executed twice...
End Sub
 
Last edited by a moderator:
Back
Top