I tried to implement this code and get an error.
Exception Details: System.Web.HttpException: Control 'chkTerms'
referenced by the ControlToValidate property of 'CVTerms' cannot be validated.
aspx:
<asp:CheckBox ID="chkTerms" runat="server" Text="I have read and agree with your <a href="#" onClick="popup('terms.asp','500','400');">Terms & Conditions</a>." />
<asp:CustomValidator ID="CVTerms" runat=server ControlToValidate="chkTerms" ErrorMessage="You must accept our Terms and Conditions." ValidationGroup="CreateUserWizard1" OnServerValidate="ValidateChkTerms" ClientValidationFunction="ValidateChkTerms" />
.vb
Protected Sub ValidateChkTerms(ByVal sender As Object, ByVal e As ServerValidateEventArgs)
Dim terms As CheckBox = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("chkTerms")
e.IsValid = terms.Checked
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim terms As CheckBox = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("chkTerms")
ClientScript.RegisterClientScriptBlock(Me.GetType(), "ValidateChkTerms", _
"function ValidateChkTerms(oSrc, args){args.IsValid = document.getElementById('" & terms.ClientID & "').checked;}", True)
End Sub
Any idea whats wrong? The Client=side validation works fine.