By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,480 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,480 IT Pros & Developers. It's quick & easy.

emit client script in check box list

P: n/a
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

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"ad**@twv.org" <an*******@discussions.microsoft.com> wrote in message
news:84**********************************@microsof t.com...
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.
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?

Adam

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.