Adding image buttons to web page programmatically

  • Thread starter Thread starter Leon
  • Start date Start date
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
 
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
 
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.
 
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
 
Back
Top