You can use a CustomValidator
for this purpose.
Within your ASPX page, you put it in your controls and the validator.
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:Label AssociatedControlID="CheckBox1" runat="server">Check this box!</asp:Label>
<asp:CheckBox ID="CheckBox2" runat="server" />
<asp:Label AssociatedControlID="CheckBox2" runat="server">And this box!</asp:Label>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="You must check all of the boxes"
OnServerValidate="CustomValidator1_ServerValidate">
</asp:CustomValidator>
After this, you can check they click Submit by checking the ServerValidate
event.
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
args.IsValid = True ' set default
If Not CheckBox1.Checked Then
args.IsValid = False
End If
If Not CheckBox2.Checked Then
args.IsValid = False
End If
End Sub
The ServerValidateEventArgs
will allow you to specify if the user has met your criteria.
At the end of ServerValidate
event, it will return the value set in the property IsValid
to determine if it's valid or not.