Creating onClick event for dynamically (programatically) created buttons

Discussion in 'ASP .Net' started by Hrvoje Vrbanc, Jul 10, 2003.

  1. Hello all!

    My question is the following: I add buttons (server controls)
    programatically into a table cell. Example:

    Dim btObnovi As Button = New Button()
    celija25.Controls.Add(btObnovi)

    The number of rows in the table depends on number of records in a database.
    Therefore, the number of buttons is variable.
    Every button, naturally, gets its own ClientID (_ctl0, ctl1, etc.). But how
    I determine which button was clicked and how do I set up OnClick event for
    particular buttons?
    I would like to take a text from a text box in the row where the button was
    clicked and then to manipulate it. But first, I need to know how to write a
    onClick sub.

    Thank you very much in advance.

    Hrvoje
    Hrvoje Vrbanc, Jul 10, 2003
    #1
    1. Advertising

  2. Hrvoje Vrbanc

    vrba Guest

    I'm speaking about adding the event handler, of course.
    I realized I didn't write what I really want clearly.

    Hrvoje

    "Hrvoje Vrbanc" <> wrote in message
    news:e7z#...
    > Hello all!
    >
    > My question is the following: I add buttons (server controls)
    > programatically into a table cell. Example:
    >
    > Dim btObnovi As Button = New Button()
    > celija25.Controls.Add(btObnovi)
    >
    > The number of rows in the table depends on number of records in a

    database.
    > Therefore, the number of buttons is variable.
    > Every button, naturally, gets its own ClientID (_ctl0, ctl1, etc.). But

    how
    > I determine which button was clicked and how do I set up OnClick event for
    > particular buttons?
    > I would like to take a text from a text box in the row where the button

    was
    > clicked and then to manipulate it. But first, I need to know how to write

    a
    > onClick sub.
    >
    > Thank you very much in advance.
    >
    > Hrvoje
    >
    >
    vrba, Jul 10, 2003
    #2
    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. Replies:
    7
    Views:
    12,419
  2. RSH
    Replies:
    1
    Views:
    401
  3. CyberMan_(MCDST!)
    Replies:
    3
    Views:
    304
    Scott Roberts
    Feb 19, 2008
  4. msimmons
    Replies:
    0
    Views:
    470
    msimmons
    Jul 16, 2009
  5. Jim Mitchell

    Accessing OnClick event for dynamically created controls.

    Jim Mitchell, Aug 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    223
    Jim Mitchell
    Aug 13, 2003
Loading...

Share This Page