Export (0) Print
Expand All

CustomValidator control

The CustomValidator control checks the user's entry using validation logic that you write yourself. This type of validation enables you to check for values derived at run time.

A CustomValidator works in conjunction with another control, for example a TextBox control. Add the control you want to validate to your page before you add the CustomValidator so that you can easily associate the CustomValidator with it.

  1. Drag the CustomValidator control from the Toolbox panel to your page.

  2. Select the CustomValidator in Design view, right-click it, and click Properties on the shortcut menu.

  3. In the Tag Properties panel, select the control you want to validate with the CustomValidator in the ControlToValidate property dropdown.

  4. To validate the control in the client browser, set the ClientValidationFunction to the name of the JavaScript function to use in validation.

    For information about writing a client or server function for use with the CustomValidator control, see How to: Validate with a Custom Function for ASP.NET Server Controls in the MSDN library.

  5. If you are going to use a ValidationSummary control to consolidate validation error messages, set the ValidationGroup property to the name of the group of validation controls. This can be any string, as long as all the controls in the group have the same value.

  6. For a full description of all CustomValidator control properties, see CustomValidator in the MSDN library.

  7. For more information about using validation controls to validate user input, see How-to Topics – Validation Controls in the MSDN library.

Community Additions

ADD
Show:
© 2014 Microsoft