Results 1 to 4 of 4

Thread: Global Event Handlers

  1. #1

    Thread Starter
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    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

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    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

  3. #3
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    Re: Global Event Handlers

    I assume you mean one eventhandler that all of the dynamically generated controls can use?

  4. #4
    New Member
    Join Date
    Feb 2005
    Posts
    9

    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
  •  



Click Here to Expand Forum to Full Width