Save state when create image

M

Mango

Hi there, I will be very happy if someone helps me. I need to create dynamic
image, and save the state between the postback. I mean I've got 5 buttons
and when I click on one of them, the image is creted with:

System.Web.UI.WebControls.Image Img1 = new
System.Web.UI.WebControls.Image();

Img1.ImageUrl = newPath;

Panel1.Controls.Add(Img1);

That's work fine but when I click on some of the other buttons I lost the
Image.

I tried this:

System.Web.UI.WebControls.Image Img1 = new
System.Web.UI.WebControls.Image();

Panel1.Controls.Add(Img1);

Img1.ImageUrl = newPath;

But it does not help me. I cant use OnInit, so the only way which I know is
to add image in design time and do it with Panel1.visible=false ,but I am
looking for more intelligent way to do it.

Any idea?
 
G

Guest

Hi Mango
put ur image control at design and set visible to false
when u click ur button change the visibilty to true and pase ur imagepath to
it .
Hope this help:)
 
E

Eliyahu Goldin

All controls you create dynamically you have to re-create on every postback.
And, as in another response, it's much simpler to create controls in design
time and in run time just switch their visibility.

Eliyahu
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top