Attaching client side code to an imagebutton rendered in a Reapeater

  • Thread starter Thread starter Teemu Keiski
  • Start date Start date
T

Teemu Keiski

Hi,

you can access the button in Repeater's ItemCreated (or ItemDataBound) event
handler and specify the attribute there using Attributes property.
 
Hi:

I would like to attach client side code to an imagebutton that is rendered
in a Reapeater control. The client code will simply confirm if users wants
to continue with an operation. In this case it would be deleting a record.

For buttons that are placed on page at design time, I can use Add.Attributes
to achieve the above. However, controls in Reapeater are created at
runtime. How do I do this?

Thanks,
Charlie
 
I can get a reference to the button in ItemCreated using Controls[]
collection. However, when I assign the script Attribute, the event handler
is only assigned to first item in list when page is openened.

ImageButton btn = (ImageButton) e.Item.Controls[3];
btn.Attributes.Add("onclick", "return ImageButton1_onclick();");

How do I make it so all buttons rendered in page will have event handler
assigned?

Thanks,
Charlie
 
Back
Top