Posted By

housecor on 09/09/10


Tagged

checkbox checked require


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Require a checkbox to be checked:


 / Published in: C#
 

NOTE:** Can't put controltovalidate property on customvalidator for this or it'll break since checkboxes are one of the few controls that .net can't validate.

  1. <asp:CustomValidator runat="server" ID="rfvMember" OnServerValidate="cbMember_Validate" ValidateEmptyText="true" ErrorMessage="Member coverage is required." Display="None"></asp:CustomValidator>
  2.  
  3.  
  4. protected void cbMember_Validate(object sender, ServerValidateEventArgs e)
  5. {
  6. e.IsValid = cbMember.Checked;
  7. }

Report this snippet  

You need to login to post a comment.