[thelist] Dynamically Added Linkbutton EventHandler

Casey Crookston caseyc at IntelliSoftmn.com
Mon Apr 16 14:34:02 CDT 2007


I'm really hoping someone can help me out on this. I'm adding a user
control to a page that has, among other items, a link button. I'm trying
to add an event handler to that link button. The control is added just
fine, and the link button appears, but when I click on it, nothing
happens.

Sub AddControl()
control_count = control_count + 1
Dim new_control As Control = New Control()
new_control = LoadControl("admin_distribute_points_line_items.ascx")
new_control.ID = "ctlLineItems" & control_count

Dim linkButtonCalc As LinkButton = new_control.FindControl("lbCalc")
AddHandler linkButtonCalc.Click, AddressOf linkButtonCalc_Click

plhDistribute.Controls.Add(new_control)
End Sub

Protected Sub linkButtonCalc_Click(ByVal sender As Object, ByVal e As
EventArgs)
'PROBLEM: I NEVER GET HERE WHEN THE LINK BUTTON IS CLICKED
End Sub

Any ideas? Thanks!

Casey



More information about the thelist mailing list