. Net background to get the value of CheckBoxList,. netcheckboxlist
. Net background to obtain the CheckBoxList value.
1. Front-end multi-choice controls
2. Obtain multiple values in the background
String str = string. Empty;
Foreach (ListItem li in cblStr. Items)
{
If (li. Selected = true)
{
Str + = li. Value + ",";
}
}
Str. TrimEnd (','); is the multiple values you need
Third: assign a value to the CheckBoxList
Foreach (string str in split)
{
For (int I = 0; I <CheckBoxList1.Items. Count; I ++)
{
If (CheckBoxList1.Items [I]. Text = str)
{
CheckBoxList1.Items [I]. Selected = true;
}
}
}
Type 4: determine whether or not to select
Var flag1 = 0;
Var checkobj = document. getElementById ("CheckBoxList1 ");
Var checks = checkobj. getElementsByTagName ("input ");
For (var n = 0; n {
If (checks [n]. type = "checkbox" & checks [n]. checked = true)
{
Flag1 = 1;
}
}
If (flag1 = 0)
{
Alert ("Select Topic settings! ");
Return false;
}