Creating an Event Handler for dymanically generated controls

Discussion in 'ASP .Net' started by Steve Caliendo, Apr 15, 2004.

  1. Hi,

    My last post was not worded correctly. What I really need to know is how
    (what to type) to create an event handler for some ImageButtons that I
    generate at run-time. I tried this:

    Private Sub ImageButton_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs)

    Stop

    End Sub



    But the stop statement was not encountered after clicking on the
    ImageButtons.



    Thanks for any help,



    Steve
     
    Steve Caliendo, Apr 15, 2004
    #1
    1. Advertising

  2. Steve Caliendo

    ashish Guest

    after the control has been generated in the code do

    AddHandler CType(Page.FindControl("MyGeneratedControl"),
    ImageButton).Click, ImageButton_Click

    hth
    -ashish




    Steve Caliendo wrote:

    > Hi,
    >
    > My last post was not worded correctly. What I really need to know is how
    > (what to type) to create an event handler for some ImageButtons that I
    > generate at run-time. I tried this:
    >
    > Private Sub ImageButton_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    >
    > Stop
    >
    > End Sub
    >
    >
    >
    > But the stop statement was not encountered after clicking on the
    > ImageButtons.
    >
    >
    >
    > Thanks for any help,
    >
    >
    >
    > Steve
    >
    >
    >
    >
    >
    >
     
    ashish, Apr 15, 2004
    #2
    1. Advertising

  3. Steve Caliendo

    Raterus Guest

    Is this what you are after?

    Private Sub ImageButton_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
    'do something
    End Sub

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

    Dim btn As ImageButton = new ImageButton
    AddHandler btn.Command, AddressOf ImageButton_Command

    End Sub

    --Michael

    "Steve Caliendo" <> wrote in message news:e3%...
    > Hi,
    >
    > My last post was not worded correctly. What I really need to know is how
    > (what to type) to create an event handler for some ImageButtons that I
    > generate at run-time. I tried this:
    >
    > Private Sub ImageButton_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    >
    > Stop
    >
    > End Sub
    >
    >
    >
    > But the stop statement was not encountered after clicking on the
    > ImageButtons.
    >
    >
    >
    > Thanks for any help,
    >
    >
    >
    > Steve
    >
    >
    >
    >
    >
    >
     
    Raterus, Apr 15, 2004
    #3
  4. Yes, Thanks All !

    Steve

    "Raterus" <raterus@localhost> wrote in message
    news:...
    Is this what you are after?

    Private Sub ImageButton_Command(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.CommandEventArgs)
    'do something
    End Sub

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

    Dim btn As ImageButton = new ImageButton
    AddHandler btn.Command, AddressOf ImageButton_Command

    End Sub

    --Michael

    "Steve Caliendo" <> wrote in message
    news:e3%...
    > Hi,
    >
    > My last post was not worded correctly. What I really need to know is how
    > (what to type) to create an event handler for some ImageButtons that I
    > generate at run-time. I tried this:
    >
    > Private Sub ImageButton_Click(ByVal sender As System.Object, ByVal e As
    > System.EventArgs)
    >
    > Stop
    >
    > End Sub
    >
    >
    >
    > But the stop statement was not encountered after clicking on the
    > ImageButtons.
    >
    >
    >
    > Thanks for any help,
    >
    >
    >
    > Steve
    >
    >
    >
    >
    >
    >
     
    Steve Caliendo, Apr 16, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Clive
    Replies:
    3
    Views:
    379
    Jerry III
    Aug 9, 2003
  2. Dan Bass
    Replies:
    2
    Views:
    354
    Dan Bass
    Jul 18, 2005
  3. =?Utf-8?B?V2FubmFiZQ==?=

    Creating an Event Handler

    =?Utf-8?B?V2FubmFiZQ==?=, Nov 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    314
    =?Utf-8?B?V2FubmFiZQ==?=
    Nov 28, 2006
  4. Replies:
    1
    Views:
    708
    Damien
    Feb 22, 2007
  5. Replies:
    20
    Views:
    1,755
    James Kanze
    Jun 13, 2007
Loading...

Share This Page