Click here to Skip to main content
16,013,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I have a repeter and i got a button inside the repeater and an asp image, when the button is clicked i want to change the image url of the asp:Image, but the problem i am having is that i cannot use the image in the code behind, and yes it have the runat server attribute. But when i take the asp Image out ouf the repeater i can then use the image in the code beind.

Please advise me on how to overcome this problem.

Thanks in advance.
Posted
Updated 5-Jul-11 22:52pm
v2
Comments
Ankur\m/ 6-Jul-11 6:29am    
As the other responder said, you can't use it directly.

When you use repeater control, ids of each control inside it will be replaced by something like this - RepeaterControlID_ctSomeNo_ControlID. And this is logical because the same control id cannot be used multiple times (for multiple rows in repeater control).

Use the technique he suggested.

1 solution

If you want to use asp:image button inside repeater then

You need to find out that image button using find control method.

give command name to image button, as well as command argument (as id of that image) in image button.

Use repeater Item_Command event.

and put condition

if (e.commandName == "commandName")
{
use e.commandArgument as u like.
// do code here for change image url
}
 
Share this answer
 
v2
Comments
Member 7871170 6-Jul-11 6:45am    
im not using the asp:image button.
Im just using th asp:Image

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900