Event doesn't work

Y

Yuriy

I added controls dynamicaly to placeholder control and
declared event to control. When I try execute event it
doesn't work on server side.
Protected WithEvents myButton1 As
System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
myButton1 = New WebControls.Button()

myButton1.EnableViewState = True
myButton1.Text = "WebControls"
PlaceHolder1.Controls.Add(myButton1)
'add event to control
AddHandler myButton1.Click, AddressOf
ButtonServer_Click
hdnControl.Text = "WebControls1"
PlaceHolder1.Controls.Add(New LiteralControl
("<br>"))

End Sub
'this is a ButtonServer_Click
Private Sub ButtonServer_Click(ByVal s As Object, ByVal e
As System.EventArgs)
Dim bt As HtmlButton
Dim strInnerText As String
bt = s
End Sub
Probably it is a some mistake. If you know the answer or
can refer me to some side i will be appriciate it.
Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top