Creating onClick event for dynamically (programatically) created buttons

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Creating onClick event for dynamically (programatically) created buttons

    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 Guest

  2. Similar Questions and Discussions

    1. Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created)
      Ok here's my scenario. I have a Custom Composite Server Control (CCSC) consisting of a TextBox, Button & Panel. (And some other code - which I...
    2. adding click event to dynamically created button
      Hi i have created a button using createObject and want to add click event and on click event want to call a function but its not working. The...
    3. events for dynamically created buttons nested in custom control
      Similar questions to this have been raised. The answers I have read seem to imply that I have to inherit to a new class in order to accomplish my...
    4. Adding dynamically user control (ASCX) into asp.net page and handling OnClick event
      Hi, I've been reading a lot's of Q&A on user controls but none seem to answer my question. Here it is. I need to add dynamically a user control,...
    5. onclick event for dynamically added controls?
      when you build the control you will need to set it's id to a unique value. then you will need to daisy chain the click event to a handler...
  3. #2

    Default Re: Creating onClick event for dynamically (programatically) created buttons

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

    Hrvoje

    "Hrvoje Vrbanc" <hrvojev@recro.hr> wrote in message
    news:e7z#MYvRDHA.212@TK2MSFTNGP10.phx.gbl...
    > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139