ganders Posted June 29, 2005 Posted June 29, 2005 (edited) 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 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 Edited June 29, 2005 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted June 29, 2005 Administrators Posted June 29, 2005 You are binding the event handler twice - once with the AddHandler statement and once using the Handles keyword. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.