|
-
Feb 9th, 2005, 03:31 PM
#1
Thread Starter
Frenzied Member
Global Event Handlers
Does anyone know if it is possible to create a global event handler(s) for dynamic controls???
If not, is there a work around?
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
Feb 9th, 2005, 03:49 PM
#2
Re: Global Event Handlers
I don't understand what you mean by a "global" event handler.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 9th, 2005, 05:29 PM
#3
Frenzied Member
Re: Global Event Handlers
I assume you mean one eventhandler that all of the dynamically generated controls can use?
-
Feb 9th, 2005, 05:40 PM
#4
New Member
Re: Global Event Handlers
If you want to add an eventhandler to like an array of controls that you dynamically add to the page, here is one way to do this:
Code:
Protected WithEvents btn As System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim i As Integer
For i = 0 To 3
btn = New System.Web.UI.WebControls.Button
btn.Text = "blabla"
btn.ID = i
AddHandler btn.Click, AddressOf btn_Click
Me.Controls.Add(btn)
Next
btn = Nothing
End Sub
Private Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = sender.id
End Sub
Have Fun!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|