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
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:uT****************@TK2MSFTNGP09.phx.gbl...
Hi,
you can access the button in Repeater's ItemCreated (or ItemDataBound)
event handler and specify the attribute there using Attributes property.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Charlie@CBFC" <ch*****@comcast.net> wrote in message
news:eM****************@TK2MSFTNGP10.phx.gbl... 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