473,513 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checkboxlist - items on change event

i've tried to add an onchange event to my checkboxes(created dynamically)

chkboxlist.attributes.add("onchange", "dothat();")

but it renders the onchange to the table it creates and not to the list
items. I need to add the onchange event to all the checkbox(s) that are
created dynamically. I've even tried

dim li as ListItem
for each li in chkboxlist
li.attributes.add("onchange", "dothat();")
next

but it still renders to the table that the chkboxlist creates rather than
the items.

Can this be done? If so can someone give some good examples?
thanks!

jason
Aug 1 '08 #1
1 1832

"Jason Hartsoe" <jh******@laneventure.comÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:u9**************@TK2MSFTNGP04.phx.gbl...
i've tried to add an onchange event to my checkboxes(created dynamically)

chkboxlist.attributes.add("onchange", "dothat();")

but it renders the onchange to the table it creates and not to the list
items. I need to add the onchange event to all the checkbox(s) that are
created dynamically. I've even tried

dim li as ListItem
for each li in chkboxlist
li.attributes.add("onchange", "dothat();")
next

but it still renders to the table that the chkboxlist creates rather than
the items.

Can this be done? If so can someone give some good examples?
thanks!

jason
Do it on the Client side.
<script type="text/javascript">
var chks = document.getElementsByName('checkboxlist');
if(chks && chks.length)
for(var i=0,N=chks.length; i<N; i++)
chks[i].onclick=dothat;

function dothat() {//your code}
</script>
Aug 4 '08 #2

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

Similar topics

3
5443
by: Robin Day | last post by:
I run some code on the changed event of checkbox lists. Its quite simple, nothing more than showing / hiding some other parts of the page. Using Autopostback and Server side code works fine, but is...
4
8060
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
3
2903
by: I am Sam | last post by:
I keep getting the following error message when I try to iterate through a CheckBoxList control: Object reference not set to an instance of an object. Description: An unhandled exception...
5
13374
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
4
4029
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
7
2219
by: ThunderMusic | last post by:
Hi, I have a CheckBoxList and I want to add some javascript code to each CheckBox created by this CheckBoxList. I tried iterating through all items of the list, all the controls, do a FindControl,...
0
2132
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
0
10982
by: jeremy | last post by:
Had a tough time figuring this one out and couldn't find a good solution, so I thought I would post this and hopefully it will help someone out. When using DataBind to dynamically bind a list to...
3
3478
by: | last post by:
Hi all, I have a CheckBoxList control which has about 10 items. I have set autopostback=true and also set an eventhandler for OnSelectedIndexChanged. The problem is I want to identify which...
3
5856
by: onlyprad | last post by:
Hi, I am populating the checkboxlist in (!IsPostBack) block of page load event with some checked items. After populating with checked items I am iterating through the items collection and...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7521
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.