void Check_Clicked(Object sender, EventArgs e) { Message.Text = "Selected Item(s):<br><br>"; // Iterate through the Items collection of the CheckBoxList // control and display the selected items. for (int i=0; i<checkboxlist1.Items.Count; i++) { if (checkboxlist1.Items[i].Selected) { Message.Text += checkboxlist1.Items[i].Text + "<br>"; } } }
{
return
}
function ifCheck()
{
if(Form.CheckBoxList == undefined)
{
alert('请选择!');
return false;
}
else
{
return true;
}}
</script>
{ Message.Text = "Selected Item(s):<br><br>"; // Iterate through the Items collection of the CheckBoxList
// control and display the selected items.
for (int i=0; i<checkboxlist1.Items.Count; i++)
{ if (checkboxlist1.Items[i].Selected)
{ Message.Text += checkboxlist1.Items[i].Text + "<br>"; } } }
用这个吧
给你写个
<script language="javascript">
function MultiValidator()
{
for(var i=0; i< document.Form1.elements.length; i++)
{
var e = document.Form1.elements[i];
if( (e.type=='checkbox') && e.name.indexOf('YourCheckBoxListID') >=0 && (e.checked == true) )
{
return true;
}
}
alert("请至少选择一项");
return false;
}
</script>
哈哈
记得给分啊!