Attaching client side code to an imagebutton rendered in a Reapeater

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.
 
C

Charlie@CBFC

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
 
C

Charlie@CBFC

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
 
S

shokiegupta

Dear Charlie,
Thanks a ton for the sample code. It worked great for me.

Ashok Gupta
 

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