2012-02-10 226 views
1

我想做客户端自定义验证。我在我的aspx页面下面的代码,但我不断收到一个错误说客户端自定义验证程序

System.Web.HttpException(0X80004005):控制“chkList_Counts” 通过的“validationCheck” 无法验证ControlToValidate属性引用。在 System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(字符串 名,字符串propertyName的)在 System.Web.UI.WebControls.CustomValidator.ControlPropertiesValid()在 System.Web.UI.WebControls.BaseValidator.OnPreRender( EventArgs e)at System.Web.UI.Control.PreRenderRecursiveInternal()at

我甚至看不到我的页面。我在页面显示之前立即发现错误。

下面是我的代码

<div> 
      <asp:Panel ID="panel3" runat="server" CssClass="cis_edit_pnl" 
       GroupingText="Counts" Width="1240px"> 
       <asp:CheckBoxList ID="chkList_Counts" runat="server" 
        RepeatDirection="Horizontal" 
        RepeatColumns="3" Width="1060px"> 
       </asp:CheckBoxList> 
       <asp:CustomValidator ID="validationCheck" runat="server" ControlToValidate="chkList_Counts" ClientValidationFunction="check_checkBoxList" EnableClientScript="true" ErrorMessage="At least one of the check boxes should be checked"> 
       </asp:CustomValidator> 
     </asp:Panel> 
    </div> 

和我的javascript功能就像是提前这

function check_checkBoxList(sender, args) { 
     debugger; 
     if (check_Counts() == false) { 
      args.IsValid = false; 
      return; 
     } 
     args.IsValid = true; 
     return; 
    } 

function check_casrepCounts() { 
     var control; 
     control = document.getElementById("<%=chkList_Counts.ClientID %>").getElementsByTagName("input"); 
     if (eval(control)) { 

      for (var i = 0; i < control.length; i++) { 
       if (control[i].checked == true) 
        return true; 
      } 
      return false; 
     } 
    } 

感谢。

+0

什么是'调试器;'? – jrummell 2012-02-10 19:27:07

+0

这可能有助于http://codeclimber.net.nz/archive/2007/07/19/How-to-add-a-required-validator-to-a-CheckBoxList.aspx – jrummell 2012-02-10 19:28:34

回答

0

它现在正常工作,我只需要删除controlToValidate和它的工作。

相关问题