View Full Version : Which element caused postback?

Dec 17th, 2005, 08:36 AM

I am currently creating a .ascx file to make my own user control which will display images and works something like a dropdownlist. When user select the image, the selected image will be selected just like the dropdownlist. I will create the <input type="image"> for each image file in the specified folder. Which makes my user control dynamic.

I have 2 labels called: lblAll and lblDisplay. lblDisplay: Shows the selected image and lblAll: shows the rest of the remaining images. The <input type="image"> will be placed inside the lblAll and lblDisplay. I have used the <div> tags to expand and collaspe the labels accordingly.

The reason i decided to use <input type="image"> is because i would like a postback so that i can update the newly selected image.

My problem: How am i supposed to know which <input type="image"> was clicked/selected during postback? Thanks

Dec 17th, 2005, 10:55 PM
Here (http://www.w3schools.com/aspnet/showasp.asp?filename=demo_htmlinputimage) is a demo that uses HtmlInputImage, which is what you're talking about. That uses a couple of different images, so you can see which one triggered the postback. Hope it helps.

Dec 18th, 2005, 09:19 AM

This link is fantastic! Thank you, im sure it will help me a lot. Thanks again! :thumbsup: