473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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(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

Nov 18 '05 #1
1 908
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!
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
0
by: R Reyes | last post by:
Hi. I'm trying to make some event handlers for buttons that are nested within datalists, however I keep getting errors trying to access them and a blank page shows w/o any real error message. How...
1
by: Boban Dragojlovic | last post by:
The Concept: I dynamically create an HTML table (with many rows) each with its own button. When the user clicks on the button, I wan't to know which row's button they clicked. The Details:...
2
by: RA | last post by:
Hi I have a dynamic asp.net table created from the database. I am adding an ImageButton to each row so the client can click on it. Each ImageButton has the ID = orderid from database. How can I...
0
by: ross | last post by:
Hi All, I have a parent class in which I keep several buttons and their event handlers. Once I upgraded to 2.0 the event handlers stopped getting fired. In the aspx page I am getting the...
2
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I have created a method that dynamically creates a single button control (as a proof-of-concept, I would like to be able to create multiple buttons). I set properties on this control including an...
1
by: Dica | last post by:
i've got a script that loops through a dataset and creates dynamic web controls and event handlers: while (oDr.Read()){ RadioButton oRb = new RadioButton(); oRb.ID = oDr.ToString();...
4
by: Meganutter | last post by:
Hello all, im making a dynamic .NET page which reads downloads from a XML file. there are two controls that have handlers, a category switcher and a download streamer (so people cant surf...
2
Frinavale
by: Frinavale | last post by:
I've created a ASP.NET control that displays a "book" of schedules. It dynamically displays scheduling times and allows the user to page through the schedules. It also lets the user edit the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.