YouTip LogoYouTip

Prop Webcontrol Listcontrol Validationgroup

## ASP.NET ListControl ValidationGroup Property The `ValidationGroup` property is a member of the `ListControl` class in ASP.NET. It allows you to group validation controls and postback controls (such as buttons) together. By assigning a specific group name to this property, you can trigger validation only for a specific subset of controls on a page, rather than validating the entire page at once. This property is highly useful in complex web forms that contain multiple logical sections or forms on a single page (for example, a login form and a registration form on the same page). --- ## Definition and Usage * **Purpose:** Specifies the validation group to which the list control belongs when it triggers a postback. * **Common Scenario:** Used when a page contains multiple buttons and input controls, and you want to isolate validation to specific sections. Only the validation controls that share the same `ValidationGroup` name will be evaluated when a postback occurs. --- ## Syntax ```xml ``` ### Property Values | Property Value | Description | | :--- | :--- | | `groupName` | A string that specifies the name of the validation group to which the control belongs. | > **Note:** `SomeListControl` represents any control that inherits from the base `ListControl` class, such as `RadioButtonList`, `CheckBoxList`, `DropDownList`, or `ListBox`. --- ## Code Example The following example demonstrates how to assign a `RadioButtonList` and its associated `RequiredFieldValidator` and `Button` to the same validation group (`valGroup1`). When the "Validate" button is clicked, only the controls belonging to `valGroup1` are validated. ```xml


``` --- ## Key Considerations 1. **Case Sensitivity:** Validation group names are case-sensitive. Ensure that the `ValidationGroup` property matches exactly across the input control, the validator control, and the button control (e.g., `"valGroup1"` is different from `"ValGroup1"`). 2. **Default Behavior:** If no `ValidationGroup` is specified, all validation controls on the page belong to the default validation group and will be validated together when any postback control with `CausesValidation="true"` is clicked. 3. **Programmatic Validation:** You can trigger validation for a specific group programmatically in your code-behind using: ```csharp Page.Validate("valGroup1"); if (Page.IsValid) { // Proceed with logic } ```
← Prop Webcontrol Listbox RowsProp Webcontrol Listcontrol Te β†’