CheckBoxList: Adding onclick javascript event to each ListItem.

J

Jimmy [Used-Disks]

How can I add an onclick client-side event to each ListItem in a
CheckBoxList? I tried iterating each item and adding an onclick attribute:

foreach(ListItem Item in this.MyCheckBoxList.Items){
Item.Attributes.Add("onclick", "alert('test')");
}

Though the attributes get added (I can see them in the debugger, write them
to a label, etcetera), they are not rendered to the page.

Is there a simple workaround for this? Should I just use a repeater and do
everything manually?

Thanks -
 
J

Jimmy [Used-Disks]

Sonali said:
Hello,
I am curious, has anyone found a solution to this?

Not that I know :(. I ended up using a repeater. If I can get around to it,
I'll write a control which will allow this.
 

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,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top