Cor,
I notice the "Adding EventHandlers example" works as you posted it but when
I put the code to dynamically create the control on a button click, the event
handler doesn't execute when I click it. Do you know why?
For example:
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub mybutton_Click _
(ByVal sender As Object, ByVal e As System.EventArgs)
Dim mylabel As New Label
Me.Panel1.Controls.Add(New LiteralControl("<BR><BR>"))
Me.Panel1.Controls.Add(mylabel)
mylabel.Text = "The day is: " & DirectCast(sender, Button).Text
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mybutton As Button
Dim i As Integer
For i = 0 To New Date().DaysInMonth _
(New Date().Year, New Date().Month) - 1
mybutton = New Button
mybutton.BackColor = Drawing.Color.White
mybutton.Text = (i + 1).ToString
mybutton.Width = New Unit(30)
Me.Panel1.Controls.Add(mybutton)
AddHandler mybutton.Click, AddressOf mybutton_Click
If (i + 1) Mod 5 = 0 Then
Me.Panel1.Controls.Add(New LiteralControl("<BR>"))
End If
Next
End Sub
"Cor Ligthert" wrote:
Clearricic
This is an old however from the Google Newsgroup disapeared sample from me.
I have resent it recently in this message.
It is a kind of calendar where buttons are created on the fly
http://groups-beta.google.com/group/...07ea54b0?hl=en
I hope this helps,
Cor