emit client script in check box list

G

Guest

h

How do i get an asp checkBoxList to emit client script. I want it so that when each checkbox is clicked, i can cause some action to happen

i tried

CheckBoxList cbl = new CheckBoxList()
for(int i = 0; i < 5; i++

ListItem li = new ListItem(i.ToString(), i.ToString())
li.Attributes.Add("onclick", string.Format("alert('{0}')", i.ToString()))
cbl.Items.Add(li)


but no onclick attribute is emitted to the page
Am i doing it wrong, or is there a way around this

Ada
 
E

Eliyahu Goldin

The checkbox list translates to a table where every checkbox is an <input
.... type="checkbox ...>. The inputs have id made out of the checkbox list id
with suffix _0, _1 etc. You can make a client script that will locate the
<input...> elements and set them up for the actions you need.

Eliyahu

hi

How do i get an asp checkBoxList to emit client script. I want it so that
when each checkbox is clicked, i can cause some action to happen.
 

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

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top