I am using .Net 2 in Vs 2008 and I am trying to get the onclick event for a checkox to fire when clicked. Unfortunately it is not firing. I can see the code is added to the checkboxs html.
This is the checkboxlist:
<asp:CheckBoxList runat="server" ID="chkSides" RepeatColumns="3" RepeatDirection="Horizontal" DataValueField="ItemNo" DataTextField="ShortName" BackColor="White" OnDataBound="chkSides_OnItemDataBound" ></asp:CheckBoxList>
this is the code that set the onclick attribute:
protected void chkSides_OnItemDataBound(object sender, EventArgs e)
{
CheckBoxList chkSides = (CheckBoxList)sender;
foreach (ListItem listitem in chkSides.Items)
{
listitem.Attributes.Add("onclick", "alert('hey');");
}
}
The checkboxlist is databound and within a databound repeater.
Any ideas?
Thanks!