Handlers and dynamic buttons
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(New Web.UI.LiteralControl("<br>Qty: "))
p.Controls.Add(New Web.UI.LiteralControl(" "))
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
Re: Handlers and dynamic buttons
If I get you right, you must recreate and attach events to dynamically
added controls every time page is loaded including post backs.
blog : http://weblogs.asp.net/ngur
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
|All times are GMT. The time now is 01:57 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.