Hey,

I created button dynamicaly and added handler to it, but for some reason, event do not fire, then I press it.

What can be wrong?

VB Code:
  1. Protected WithEvents LeftPane As System.Web.UI.HtmlControls.HtmlTableCell
  2.  
  3.  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.             If Page.IsPostBack = False Then
  5.  
  6.  Dim myButton As New Button
  7.                     myButton.Text = "Save"
  8.                     myButton.ID = "SubmitButton"
  9.                     AddHandler myButton.Click, AddressOf Me.Submitas
  10.  
  11. LeftPane.Controls.Add(myButton)
  12.  
  13.  
  14.             End If
  15.  
  16. End Sub
  17.  
  18.         Private Sub Submitas(ByVal sender As System.Object, ByVal e As System.EventArgs)
  19.  
  20.             Response.Write("Click")
  21.         End Sub