G
Guest
I'm trying to process the Onclick event of my page but it's never working. The button is dynamical added to the sites MainPanel. If I click on the button the PageLoad Event is processed but no event method called. How can I fix?
Thanks a lot
Steven
Here is my example code:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents MainPanel As System.Web.UI.WebControls.Panel
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected WithEvents Button As New System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Design_Page()
End If
End Sub
Private Sub Design_Page()
Button.ID = "Button"
Button.Style.Add("position", "absolute")
Button.Width = Unit.Pixel(30)
Button.Height = Unit.Pixel(30)
MainPanel.Controls.Add(Button)
End Sub
Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button.Click
End Sub
End Class
Thanks a lot
Steven
Here is my example code:
Public Class WebForm1
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents MainPanel As System.Web.UI.WebControls.Panel
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Protected WithEvents Button As New System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Design_Page()
End If
End Sub
Private Sub Design_Page()
Button.ID = "Button"
Button.Style.Add("position", "absolute")
Button.Width = Unit.Pixel(30)
Button.Height = Unit.Pixel(30)
MainPanel.Controls.Add(Button)
End Sub
Private Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button.Click
End Sub
End Class