Handlers and dynamic buttons

Discussion in 'ASP .Net' started by noone, Jan 27, 2004.

  1. noone

    noone Guest

    Below are the guts to a function that returns a textbox and button. A
    handler is added to the button. All this is done in a class separate from
    the code behind including the Handler.

    So here is the problem, unless I regenerate the buttons, when I post back
    the handler for the button pressed does not fire. What do I need to do to
    make this handler work?





    Dim p As New PlaceHolder
    Dim btn As New ImageButton
    Dim txt As New TextBox
    txt.Text = "1"
    txt.ID = "txt" & Detail.Asin

    txt.Width = Unit.Pixel(20) '
    txt.EnableViewState = True

    btn.CommandArgument = Detail.Asin

    btn.ImageUrl = "amzImages/add-to-cart-02.gif"

    btn.ID = "btn" & Detail.Asin

    btn.EnableViewState = True

    AddHandler btn.Click, AddressOf Purchase_AddToCart

    p.Controls.Add(btn)

    p.Controls.Add(New Web.UI.LiteralControl("<br>Qty: "))

    p.Controls.Add(txt)

    p.Controls.Add(New Web.UI.LiteralControl("&nbsp"))

    Return p



    x-- 100 Proof News - http://www.100ProofNews.com
    x-- 3,500+ Binary NewsGroups, and over 90,000 other groups
    x-- Access to over 800 Gigs/Day - $8.95/Month
    x-- UNLIMITED DOWNLOAD
    noone, Jan 27, 2004
    #1
    1. Advertising

  2. noone

    Natty Gur Guest

    Hi,

    If I get you right, you must recreate and attach events to dynamically
    added controls every time page is loaded including post backs.

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur, Jan 27, 2004
    #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. Boban Dragojlovic

    Dynamic Buttons and Event Handlers, revisited

    Boban Dragojlovic, Jun 24, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,865
    Boban Dragojlovic
    Jun 24, 2003
  2. Michael Dawson
    Replies:
    3
    Views:
    453
    Karl Seguin [MVP]
    Feb 22, 2006
  3. Chris

    Dynamic event handlers and code

    Chris, Aug 23, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    480
    Marina Levit [MVP]
    Aug 24, 2006
  4. Nessuno

    Buttons and Event Handlers

    Nessuno, Feb 21, 2010, in forum: Java
    Replies:
    7
    Views:
    386
  5. Replies:
    2
    Views:
    242
Loading...

Share This Page