MikeDamone
Programmer
I have a series of dynamic controls that are created by the same sub. There are textboxes, buttons and dropdowns all being created together.
The click event of the buttons are not firing even though they an AddHandler has been added. I know the dynamic controls are being rendered correctly after a postback because any value I add to the textboxes is still present.
Also, the exact same code worked fine in VS 2003 but when the project was upgraded to VS 2005, the button click events are not firing. Can anyone help? Thanks! Here is a portion of the code:
Protected Overrides Sub MakeControls
txt = New TextBox
With txt
.Text = Me._SelectedValue
.Visible = True
End With
Controls.Add(txt)
btn = New Button
With btn
.Text = "Find"
.Visible = True
End With
AddHandler btn.Click, AddressOf MyClick
Controls.Add(btn)
ddl = New DropDownList
ddl.Visible = False
Controls.Add(ddl)
MyBase.MakeControls()
End Sub
Public Sub MyClick(ByVal sender As Object, ByVal e As EventArgs)
'Some code that is never being fired
End Sub
The click event of the buttons are not firing even though they an AddHandler has been added. I know the dynamic controls are being rendered correctly after a postback because any value I add to the textboxes is still present.
Also, the exact same code worked fine in VS 2003 but when the project was upgraded to VS 2005, the button click events are not firing. Can anyone help? Thanks! Here is a portion of the code:
Protected Overrides Sub MakeControls
txt = New TextBox
With txt
.Text = Me._SelectedValue
.Visible = True
End With
Controls.Add(txt)
btn = New Button
With btn
.Text = "Find"
.Visible = True
End With
AddHandler btn.Click, AddressOf MyClick
Controls.Add(btn)
ddl = New DropDownList
ddl.Visible = False
Controls.Add(ddl)
MyBase.MakeControls()
End Sub
Public Sub MyClick(ByVal sender As Object, ByVal e As EventArgs)
'Some code that is never being fired
End Sub