我試圖創建一個自定義驗證器來驗證複選框,並得到此錯誤: 「無法驗證」ControlValidator1「的ControlToValidate屬性所引用的」Control'cbVerify'「。自定義驗證器錯誤
這裏是前端代碼我對這個:
<li>
<asp:CheckBox ID="cbVerify" runat="server" Text="I certify that the information entered on this form is correct and accurate." />
</li>
<li>
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please check" Display="Dynamic" ControlToValidate="cbVerify" OnServerValidate="CustomValidator1_ServerValidate" CssClass="ValidationError"></asp:CustomValidator>
</li>
後端:
protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = cbVerify.Checked ;
}
我能得到一些幫助搞清楚了這一點?