473,382 Members | 1,657 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Attaching client side code to an imagebutton rendered in a Reapeater

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
Nov 18 '05 #1
3 1361
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

Nov 18 '05 #2
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


Nov 18 '05 #3
Dear Charlie,
Thanks a ton for the sample code. It worked great for me.

Ashok Gupta

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sue | last post by:
For performance purposes, I am using client-side scripts to show-hide (via css display: hide, display: block) several rows of a table depending on which imagebutton is clicked. Because of workplace...
1
by: Jon | last post by:
Can you add client side controls inside a asp .net datagrid? The code below shows what I have template column inside a asp .net datagrid... <Columns> <asp:TemplateColumn HeaderText="Exist Or...
11
by: Hrvoje Vrbanc | last post by:
Hello, I have the following problem: I have a DataGrid control on my page with a column with TextBox controls and another one with ImageButton controls. In order to force a call to JavaScript...
2
by: Guadala Harry | last post by:
In an aspx file I have declared a hidden field like this: <input id="hTestVal" type=hidden value="-1" runat="server"> Defined in the code-behind like this: protected...
3
by: jw56578 | last post by:
I have a reapeater where each repeater item contains several table rows. The table rows, in turn, contain several child objects. when everthing is rendered, the client ids are constructed as such ...
3
by: Guadala Harry | last post by:
I hope this is something I can solve without contacting the vendor: I'm implementing a 3rd party component that will, by itself, initiate a PostBack. Apparently it does not support the...
2
by: jack-e | last post by:
Hi there, I have a form with 3 textboxes, each with a server side validiation control. When the form submits I am wanting to display a message like 'Processing request.. please wait.' so they...
2
by: NH | last post by:
I have a gridview with a delete button as follows... <ItemTemplate> <asp:ImageButton id="deleteAttachment" OnClientClick='return confirm("Are you sure you want to delete this Attachment?");'...
7
by: =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ== | last post by:
I am having trouble getting client-side events to fire on ImageButtons. Instead I am seeing postbacks. The client-side handlers end with "return false;" but they are never called. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.