---
title: "一个Page页面多个CheckBoxList的客户端验证(.net1.1及2.0实现)(downmoon)"
author: "netxdiy"
date: "2007-07-26T18:47:00Z"
tags: []
slug: "page-checkboxlist-net1-1-2-0-downmoon"
draft: false
lastmod: "2012-09-27T11:33:06Z"
id: 1687119
url: "https://netxdiy.iteye.com/blog/1687119"
---

一，基于.net1.1  
1、类文件

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Web.UI;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Web;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Web.UI.WebControls;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Text;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)namespaceAgrExibition.Common.Framework.Util...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)[欢迎与邀月交流,net技术与软件架构](http://blog.csdn.net/downmoon/ "邀月工作室")2007/07/26#regiondownmoon2007/07/26  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///一个Page页面多个CheckBoxList的客户端验证(.net1.1实现)(downmoon)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)#endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicclassRadioButtonListRequiredFieldValidator:BaseValidator  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedoverrideboolControlPropertiesValid()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returntrue;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedoverrideboolEvaluateIsValid()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returnthis.EvaluateIsChecked();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedboolEvaluateIsChecked()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)ListControl\_listcontrol=((ListControl)this.FindControl(this.ControlToValidate));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)foreach(ListItemliin\_listcontrol.Items)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(li.Selected)returntrue;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returnfalse;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedoverridevoidOnPreRender(EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)if(this.EnableClientScript)...{this.ClientScript();}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)base.OnPreRender(e);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedvoidClientScript()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.Attributes\["evaluationfunction"]="cb\_vefify";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)StringBuildersb\_Script=newStringBuilder();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("&lt;scriptlanguage="javascript"&gt;");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("functioncb\_vefify(val){");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("varval=document.getElementById(val.controltovalidate);");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("varcol=val.all;");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("if(col!=null){");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("for(i=0;i&lt;col.length;i++){");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("if(col.item(i).tagName.toUpperCase()=="INPUT"){");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("if(col.item(i).checked){");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("returntrue;");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("}");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("}");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("}");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("returnfalse;");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("}");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("}");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append(" ");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)sb\_Script.Append("&lt;/script&gt;");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(!this.Page.IsClientScriptBlockRegistered("RBLScript"))  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.Page.RegisterClientScriptBlock("RBLScript",sb\_Script.ToString());  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

2、页面

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)&lt;%...@RegisterTagPrefix="AgrExibition"Namespace="AgrExibition.Common.Framework.Util"Assembly="AgrExibition.Common.Framework"%&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:CheckBoxListid="cbB\_Property"runat="server"RepeatDirection="Horizontal"RepeatColumns="3"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="1"&gt;投资商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="2"&gt;投资促进机构&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="3"&gt;代理商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="4"&gt;科研及信息单位协会&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="5"&gt;零售商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="6"&gt;批发商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="7"&gt;仓储业&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="8"&gt;跨国公司&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="9"&gt;进出口商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="10"&gt;生产商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="11"&gt;超市&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="12"&gt;酒店&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="13"&gt;宾馆及后勤服务&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="-1"&gt;其他&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/asp:CheckBoxList&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:TextBoxid="txtB\_Property"Runat="Server"CssClass="input2"Width="400px"/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;AgrExibition:RADIOBUTTONLISTREQUIREDFIELDVALIDATORid="rbValid1"Display="Dynamic"ErrorMessage="请选择或输入业务性质！"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)runat="server"ControlToValidate="cbB\_Property"Text="\*"&gt;\*&lt;/AgrExibition:RADIOBUTTONLISTREQUIREDFIELDVALIDATOR&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:CheckBoxListid="cbPurpose"runat="server"RepeatDirection="Horizontal"RepeatColumns="3"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="1"&gt;采购产品&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="2"&gt;搜集市场信息&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="3"&gt;与业务伙伴会面&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="4"&gt;了解行业动向&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="5"&gt;观看观摩&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="6"&gt;投资项目洽谈&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="7"&gt;获取行业信息&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="8"&gt;寻找供应商或买家&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="-1"&gt;其他&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/asp:CheckBoxList&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:TextBoxid="txtPurpose"Runat="Server"CssClass="input2"Width="400px"/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;AgrExibition:RADIOBUTTONLISTREQUIREDFIELDVALIDATORid="rbValid2"Display="Dynamic"ErrorMessage="请选择或输入参会目的!"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)runat="server"ControlToValidate="cbPurpose"Text="\*"&gt;\*&lt;/AgrExibition:RADIOBUTTONLISTREQUIREDFIELDVALIDATOR&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ValidationSummaryid="ValidationSummary1"runat="server"ShowMessageBox="True"ShowSummary="False"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)HeaderText="请检查输入表单内容:"&gt;&lt;/asp:ValidationSummary&gt;

二、基于.net 2.0  
1、类文件

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Collections.Generic;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.ComponentModel;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Text;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Web;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Web.UI;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)usingSystem.Web.UI.WebControls;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)namespaceShiXun.Commoon.Web.Validor  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)[欢迎与邀月交流,net技术与软件架构](http://blog.csdn.net/downmoon/ "邀月工作室")2007/07/26#regiondownmoon2007/07/26  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///一个Page页面多个CheckBoxList的客户端验证(.net2.0实现)(downmoon)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)#endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)\[DefaultProperty("ErrorMessage"),ToolboxData("&lt;{0}:ListControlRequiredFieldValidatorrunat=server&gt;&lt;/{0}:ListControlRequiredFieldValidator&gt;")]  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)publicclassListControlRequiredFieldValidator:BaseValidator  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///ValidatorRequirement  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///&lt;returns&gt;Trueifdependenciesarevalid.&lt;/returns&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedoverrideboolControlPropertiesValid()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)ControlcontrolToValidate=FindControl(ControlToValidate)asListControl;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)return(controlToValidate!=null);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///ValidatorRequirement  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///&lt;returns&gt;trueifControlToValidate  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///hasoneitemormoreselected&lt;/returns&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedoverrideboolEvaluateIsValid()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returnthis.EvaluateIsChecked();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///Returntrueifaniteminthelistisselected.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///&lt;returns&gt;trueifControlToValidate  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///hasoneitemormoreselected&lt;/returns&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedboolEvaluateIsChecked()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)ListControllistToValidate=((ListControl)this.FindControl(this.ControlToValidate));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)foreach(ListItemliinlistToValidate.Items)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(li.Selected==true)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returntrue;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returnfalse;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///PreRender  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///&lt;paramname="e"&gt;&lt;/param&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedoverridevoidOnPreRender(EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)System.Web.HttpContext.Current.Trace.Write("OverrideOnPreRender");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(this.DetermineRenderUplevel()&&this.EnableClientScript)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)Page.ClientScript.RegisterExpandoAttribute(this.ClientID,"evaluationfunction","ListItemVerify");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)Page.ClientScript.RegisterExpandoAttribute(this.ClientID,"minimumNumberOfSelectedCheckBoxes","1");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//System.Web.UI.Page.(this.ClientID,"evaluationfunction","ListItemVerify");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//Page.ClientScript.RegisterExpandoAttribute(this.ClientID,"minimumNumberOfSelectedCheckBoxes","1");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)//TODO:imporovetoallowvariablenumber.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.RegisterClientScript();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)else  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.Attributes.Remove("evaluationfunction");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)base.OnPreRender(e);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)/\*\*////&lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)///Registertheclientscript.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)///&lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)protectedvoidRegisterClientScript()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)stringscript=@"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)&lt;scriptlanguage=""javascript""&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)functionListItemVerify(val)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif){  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)varcontrol=document.getElementById(val.controltovalidate);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)varminimumNumberOfSelectedCheckBoxes=parseInt(val.minimumNumberOfSelectedCheckBoxes);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)varselectedItemCount=0;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)varliIndex=0;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)varcurrentListItem=document.getElementById(control.id+'\_'+liIndex.toString());  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)while(currentListItem!=null)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif){  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)if(currentListItem.checked)selectedItemCount++;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)liIndex++;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)currentListItem=document.getElementById(control.id+'\_'+liIndex.toString());  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)returnselectedItemCount&gt;=minimumNumberOfSelectedCheckBoxes;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)&lt;/script&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)this.Page.ClientScript.RegisterClientScriptBlock(typeof(ListControlRequiredFieldValidator),"ListRequiredValidator\_Script",script);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)

2、页面

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)&lt;%...@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="\_Default"%&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)&lt;%...@RegisterTagPrefix="ShiXun"NameSpace="ShiXun.Commoon.Web.Validor"Assembly="ShiXun.Commoon.Web.Validor"%&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;htmlxmlns="http://www.w3.org/1999/xhtml"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;headrunat="server"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;title&gt;无标题页&lt;/title&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/head&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;body&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;formid="form1"runat="server"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:CheckBoxListid="cbB\_Property"runat="server"RepeatDirection="Horizontal"RepeatColumns="3"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="1"&gt;投资商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="2"&gt;投资促进机构&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="3"&gt;代理商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="4"&gt;科研及信息单位协会&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="5"&gt;零售商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="6"&gt;批发商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="7"&gt;仓储业&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="8"&gt;跨国公司&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="9"&gt;进出口商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="10"&gt;生产商&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="11"&gt;超市&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="12"&gt;酒店&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="13"&gt;宾馆及后勤服务&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="-1"&gt;其他&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/asp:CheckBoxList&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;ShiXun:ListControlRequiredFieldValidator  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)ControlToValidate="cbB\_Property"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)display="Dynamic"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)ErrorMessage="至少选择一项！"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)EnableClientScript="true"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)runat="Server"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)至少选择一项  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/ShiXun:ListControlRequiredFieldValidator&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:CheckBoxListID="cbPurpose"runat="server"RepeatColumns="3"RepeatDirection="Horizontal"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="1"&gt;采购产品&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="2"&gt;搜集市场信息&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="3"&gt;与业务伙伴会面&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="4"&gt;了解行业动向&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="5"&gt;观看观摩&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="6"&gt;投资项目洽谈&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="7"&gt;获取行业信息&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="8"&gt;寻找供应商或买家&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="-1"&gt;其他&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/asp:CheckBoxList&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;ShiXun:ListControlRequiredFieldValidator  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)ControlToValidate="cbPurpose"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)display="Dynamic"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)ErrorMessage="至少选择一项！"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)EnableClientScript="true"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)runat="Server"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)至少选择一项  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/ShiXun:ListControlRequiredFieldValidator&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:CheckBoxListID="cbChannel"runat="server"RepeatColumns="3"RepeatDirection="Horizontal"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="1"&gt;报纸等平面媒体&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="2"&gt;网络&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="3"&gt;电视&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="4"&gt;朋友介绍&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="5"&gt;客户推荐&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ListItemValue="-1"&gt;其他&lt;/asp:ListItem&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/asp:CheckBoxList&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;ShiXun:ListControlRequiredFieldValidator  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)ControlToValidate="cbChannel"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)display="Dynamic"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)ErrorMessage="至少选择一项！"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)EnableClientScript="true"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)runat="Server"&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)至少选择一项  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/ShiXun:ListControlRequiredFieldValidator&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:TextBoxID="txtSourceChannel"runat="Server"CssClass="input2"Width="400px"&gt;&lt;/asp:TextBox&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;br/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;asp:ButtonID="Button1"runat="server"Text="Button"/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/form&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/body&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)&lt;/html&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)