G
Guest
Hi.
I Have a CheckBoxList and I would like the add the onclick attribute. But
when I add the attribute only the first one in my list get the onclick
attribute.
Here is my code.
protected CheckBoxList myCheckBoxList;
private void Page_Load(object sender, System.EventArgs e)
{
// Binnds myc CheckBoxlList with human with Name and Age
myCheckBoxList.DataSource = al;
myCheckBoxList.DataTextField = "Name";
myCheckBoxList.DataValueField = "Age";
myCheckBoxList.DataBind();
}
protected void myCheckBoxList_OnDataBinding(object sender, EventArgs e)
{
CheckBoxList chkList = (CheckBoxList)sender;
CheckBox cBox = (CheckBox)chkList.Controls[0];
cBox.Attributes.Add("onclick","alert('hello world');");
}
I Have a CheckBoxList and I would like the add the onclick attribute. But
when I add the attribute only the first one in my list get the onclick
attribute.
Here is my code.
protected CheckBoxList myCheckBoxList;
private void Page_Load(object sender, System.EventArgs e)
{
// Binnds myc CheckBoxlList with human with Name and Age
myCheckBoxList.DataSource = al;
myCheckBoxList.DataTextField = "Name";
myCheckBoxList.DataValueField = "Age";
myCheckBoxList.DataBind();
}
protected void myCheckBoxList_OnDataBinding(object sender, EventArgs e)
{
CheckBoxList chkList = (CheckBoxList)sender;
CheckBox cBox = (CheckBox)chkList.Controls[0];
cBox.Attributes.Add("onclick","alert('hello world');");
}