问题描述
我试图做客户端自定义验证。我在我的aspx页面下面的code,但我不断收到一个错误说
I am trying to do client side custom validation. I have the following code in my aspx page, but I keep getting an error saying
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.On preRender(EventArgs e)上
在
我甚至不能看到我的网页。我得到的错误就在在显示页面之前。
I cannot even see my page. I get the error right away before the page displays.
下面是我的code
<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函数是这样的。
and my javascript function is like this
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;
}
}
先谢谢了。
推荐答案
它正常工作,现在,我不得不删除的ControlToValidate和它的工作。
It works fine now, I just had to remove controlToValidate and it worked.
这篇关于客户端自定义的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!