By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,125 Members | 1,479 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,125 IT Pros & Developers. It's quick & easy.

User Controls Events

P: n/a

I am trying to dynamically add many instances of a user control inside
a placeholder.
The user control exposes an event raised when a button is pushed.
How can I handle such event for every user control in the placeholder?
Using the code below, the event is fired only when you press the
button of the last user control added in the placeholder.



Public WithEvents ticket As test_control

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim i As Integer
Dim tbl As New HtmlTable

For i = 1 To 10
Dim row As New HtmlTableRow
Dim cell As New HtmlTableCell
testc = New test_control

testc = DirectCast(LoadControl("test-control.ascx"),
testc.Content = "User Control number " & i
testc.EditMode = True
testc.TicketId = i

End Sub ' Page Load

Private Sub testc_Click(ByVal sender As Object, ByVal e As
EventArgs) Handles testc.Event1
'Event stuff needs to be done here
'but event happens only for last control added
End Sub ' testc_Click
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.