Hi All,

I use the event of a non-dynamic control to call a sub that creates dynamic labels, textboxes and a button and the button's event. The problem is the button's event never fires. I have autopostback set to True for the dropdownlist and the option buttons. Here follows code snippets...

Public Class TroubleTicket
Inherits System.Web.UI.Page

Protected WithEvents optMenu As RadioButtonList
Protected WithEvents lstUsers As System.Web.UI.WebControls.DropDownList

' the radio button option "Add new user" calls DisplaylstUsers()
Private Sub DisplaylstUsers()
'code here fills lstUser from a db

lstUsers.AutoPostBack = True ' Negates need for a submit button
AddHandler lstUsers.SelectedIndexChanged, AddressOf lstUsers_OnChange
end sub

Private Sub lstUsers_OnChange(ByVal sender As Object, ByVal e As EventArgs) Handles lstUsers.SelectedIndexChanged
Select Case lstUsers.SelectedItem.Text
Case "-Make a selection-"
' do nothing
Case "Add a new user"
Display_TextBoxes() ' Input boxes for new user info to add to database
Case Else
DisplayTickets(CInt(lstUsers.SelectedItem.Value)) ' All tickets for particular user
End Select
End Sub ' lstUsers_OnChange()

' in lstUsers I select "Add a new user" which calls Display_TextBoxes()
Public Sub Display_TextBoxes()
Dim btnNewUser As New System.Web.UI.HtmlControls.HtmlButton()
With btnNewUser
.ID = "btnNUser"
.InnerText = "Add New User"
.Visible = True
End With
AddHandler btnNewUser.ServerClick, New EventHandler(AddressOf dxaBtnClk)
Me.FindControl("Form1").Controls.Add(btnNewUser)
end sub

' I click btnNewUser but never get to...
Public Sub dxaBtnClk(ByVal sender As Object, ByVal e As EventArgs)
Response.Write("dxaBtnClk was clicked")
End Sub ' dxaBtnClk
End Class