19.7. Validating by Groups

A busy Web form — especially one that uses ASP.NET AJAX — can have numerous text boxes and buttons that are independent of each other. Instead of trying to validate every control on the page at the same time, you can validate controls in groups. To include controls in a group, set their ValidationGroup property to a common value.

Figure 19-6 shows the Design view of two independent validation groups on the same ASP.NET page. The upper section checks for a number from 1 to 10. The lower section includes a required field. At runtime, click OK to validate the number even though the required field is empty.

All the controls in the upper section include the ValidationGroup="Range" attribute and value pair. The controls in the lower section are grouped by the common "Required" value.

Figure 19-6. Two independent validation groups on a page.

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.