Handlers and dynamic buttons

N

noone

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top