Adding image buttons to web page programmatically

L

Leon

Hi everybody.

I am adding image buttons to web page programmatically. In each image button
I show the product info. When user clicks any button I want to pass the
product info to use it when the form is reposted. Can anyone tell me how to
do it. Whatever I try is not working for me.

Thank you in advance
 
T

ton

if you add controls at runtime you would have to add a button.click
procedure to your app. (I suppoose you've done so)
But you have to be sure that these buttons are their after the postback.
These buttons are no static controls. In your form_load procedure you have
to add these buttons again and again. If the number of buttons depends on
the click event in an earlier stage, you have to save this state (or the
result of that event) so the same buttons are added again and the
button.clck event can run.

succes

Ton
 
L

Leon

Ton, thanks for your reply.
Actually I added onclientclick and put a small java function to save the
product information, but then I am getting an error message. I'll post the
message. Please look at my next post.
 
S

S. Justin Gengo

Leon,

When adding buttons dynamically you have to recreate the buttons on
post-back in order for their events to be able to hook up.

I have an example of how to use dynamic controls on my website here:

http://www.aboutfortunate.com/Code-Repository.aspx?entryid=42

The example creates text boxes dynamically, but you'll get the idea. One
other thing - you can run into strange issues on post back of dynamically
created buttons if you haven't assigned an id to them. In your code behind
when each button is created make certain to also assign it's id:
MyDynamicButton.ID = "DynamicButton" & ButtonCount.ToString() or something
like that will work (assuming the buttons are being created in a loop).

--


Sincerely,

S. Justin Gengo, MCP

Free code library at:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top